/* Appamaton: mobile-first styles, light/dark via [data-theme]. */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --border: #e3e6ea;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --error: #c0392b;
  --code-bg: #f0f1f3;
  --ghost: #b9bfc8; /* streaming code, light mode */
}

html[data-theme="dark"] {
  --bg: #111418;
  --card: #1a1e24;
  --text: #e8eaed;
  --muted: #9aa1ab;
  --border: #2a2f37;
  --accent: #14b8a6;
  --accent-text: #06251f;
  --error: #ff6b5e;
  --code-bg: #22262d;
  --ghost: #3d4450; /* streaming code, dark mode */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

header h1 { font-size: 1.15rem; margin: 0; }
.header-actions button, .header-actions a {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.1rem;
  padding: 6px 9px;
  margin-left: 6px;
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
}

a.brand { color: var(--text); text-decoration: none; }

main { max-width: 720px; margin: 0 auto; padding: 16px; }

section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

label { display: block; font-weight: 600; margin-bottom: 6px; }

textarea, input[type="text"], input[type="password"], input[type="number"] {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 10px;
}

textarea { resize: vertical; min-height: 72px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.9rem;
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

button { touch-action: manipulation; }

#view-progress pre {
  background: var(--code-bg);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.75rem;
  height: 180px; /* fixed box so the layout never shifts while streaming */
  overflow: hidden; /* no scrollbar; JS pins scrollTop to the bottom edge */
  white-space: pre; /* no soft-wrapping: one display line per source line */
  color: var(--ghost); /* low-contrast stream, robot stays the focus */
}

.tail-wrap { position: relative; }
.tinker {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.tinker svg { width: min(52%, 160px); height: auto; overflow: visible; }
.tinker .part, .tinker .tool-shaft, .tinker .tool-tip { fill: var(--muted); }
.tinker .stroke { stroke: var(--muted); stroke-width: 4; stroke-linecap: round; fill: none; }
.tinker .thick { stroke-width: 10; }
.tinker .eye, .tinker .mouth { fill: var(--text); }
.tinker .antenna-light { fill: var(--accent); animation: tinker-blink 1.6s ease-in-out infinite; }
.tinker .screen { fill: var(--code-bg); }
.tinker .cl { fill: var(--muted); animation: tinker-code 1.5s ease-in-out infinite; }
.tinker .cl2 { animation-delay: 0.5s; }
.tinker .cl3 { animation-delay: 1s; }
.tinker .tool-handle { fill: var(--accent); }
.tinker .spark { fill: var(--accent); animation: tinker-spark 1.2s ease-in-out infinite; }
.tinker .s2 { animation-delay: 0.4s; }
.tinker .s3 { animation-delay: 0.8s; }
.tinker .bob { animation: tinker-bob 2.4s ease-in-out infinite; }
.tinker .arm { transform-origin: 140px 100px; animation: tinker-swing 1.2s ease-in-out infinite; }

@keyframes tinker-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes tinker-swing { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-18deg); } }
@keyframes tinker-spark { 0%, 100% { opacity: 0.1; } 45% { opacity: 1; } 60% { opacity: 0.3; } }
@keyframes tinker-blink { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
@keyframes tinker-code { 0%, 100% { opacity: 0.2; } 50% { opacity: 0.85; } }

@media (prefers-reduced-motion: reduce) {
  .tinker .bob, .tinker .arm, .tinker .spark, .tinker .antenna-light, .tinker .cl { animation: none; }
}

#file-details summary { cursor: pointer; font-weight: 700; font-size: 1rem; padding: 6px 0; }
#file-list { list-style: none; margin: 8px 0; padding: 0; }
#file-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.85rem;
}
.fsize { color: var(--muted); }

#warnings .error { color: var(--error); white-space: pre-wrap; }
#warnings .warning { color: #b45309; font-size: 0.9rem; margin: 4px 0; }
html[data-theme="dark"] #warnings .warning { color: #fbbf24; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 4px 0; }

iframe#preview {
  width: 100%;
  height: 480px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  margin: 10px 0;
}

.actions { display: flex; gap: 10px; margin-top: 10px; }
.actions button, .actions a {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.actions button.primary, .actions a.primary {
  width: auto;
  flex: 1.4;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  font-weight: 700;
}

.refine-row { display: flex; gap: 8px; margin-top: 4px; }
.refine-row input[type="text"] { flex: 1; width: auto; margin-bottom: 0; }
.refine-row button {
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

h2 { font-size: 1.05rem; margin: 0 0 8px; }

#history-list { list-style: none; margin: 0; padding: 0; }
#history-list li {
  border-bottom: 1px solid var(--border);
  padding: 10px 4px;
}
.hname { font-weight: 700; }
.hidea { color: var(--muted); font-size: 0.9rem; margin: 2px 0; }
.hmeta { color: var(--muted); font-size: 0.8rem; }
.hbtns { margin-top: 6px; display: flex; gap: 8px; }
.hbtns button {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
}
.muted { color: var(--muted); }

dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  padding: 18px;
  width: min(92vw, 460px);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog .row { display: flex; gap: 10px; }
dialog .row label { flex: 1; }
#set-test-result { min-height: 1.2em; font-size: 0.9rem; color: var(--muted); }

/* About page */
main p, main li { margin: 6px 0; }
main ol, main ul { padding-left: 22px; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin: 8px 0; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 700; }
code { background: var(--code-bg); border-radius: 4px; padding: 1px 5px; font-family: ui-monospace, Menlo, monospace; font-size: 0.85em; }
