:root {
  --bg: #0b1020;
  --bg-2: #131a33;
  --fg: #e7ecff;
  --fg-muted: #8a93b8;
  --accent: #ffb43c;
  --accent-dim: #8a5e12;
  --ok: #4ade80;
  --err: #f87171;
  --border: #1f274a;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

#app {
  max-width: 540px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen { flex: 1; display: flex; flex-direction: column; }
.screen.hidden { display: none; }

/* PIN screen */
#pin-screen {
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}
#pin-screen h1 {
  font-size: 2.4rem;
  margin: 0;
  letter-spacing: 0.02em;
}
#pin-screen .subtitle {
  color: var(--fg-muted);
  margin: 0 0 12px;
}
#pin-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 240px;
}
#pin-input {
  font-size: 2rem;
  text-align: center;
  letter-spacing: 0.35em;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--fg);
  outline: none;
}
#pin-input:focus { border-color: var(--accent); }
.error {
  color: var(--err);
  font-size: 0.95rem;
  margin-top: 8px;
  min-height: 1em;
}

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: #20130a;
  border: none;
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:active { background: var(--accent-dim); }
.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.topbar .title {
  font-weight: 700;
  flex: 1;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--fg-muted);
}
.dot-ok  { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot-err { background: var(--err); box-shadow: 0 0 8px var(--err); }
.dot-unknown { background: var(--fg-muted); }

/* Record area */
.record-area {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 36px 0 24px;
}
.mic-btn {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: var(--accent);
  color: #20130a;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 40px rgba(255, 180, 60, 0.25);
  transition: transform 0.1s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.mic-btn:active { transform: scale(0.97); }
.mic-btn.recording {
  background: var(--err);
  color: white;
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.5); }
  50%     { box-shadow: 0 0 0 18px rgba(248, 113, 113, 0); }
}
.mic-icon { font-size: 3.5rem; line-height: 1; }
.mic-label { font-size: 1.05rem; }
.record-status {
  color: var(--fg-muted);
  min-height: 1.4em;
  font-size: 0.95rem;
  text-align: center;
  margin: 0;
}
.record-status.ok  { color: var(--ok); }
.record-status.err { color: var(--err); }

/* Text fallback */
.text-fallback {
  margin: 8px 0 18px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.text-fallback summary {
  color: var(--fg-muted);
  cursor: pointer;
  padding: 6px 0;
  font-size: 0.95rem;
}
#text-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
#text-input {
  flex: 1;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--fg);
  font-size: 1rem;
  outline: none;
}
#text-input:focus { border-color: var(--accent); }

/* History */
.history h2 {
  font-size: 0.95rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 14px 0 10px;
  font-weight: 600;
}
#history-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#history-list li {
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.95rem;
}
#history-list li .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
#history-list li .text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#history-list li .meta {
  font-size: 0.75rem;
  color: var(--fg-muted);
}
#history-list li.status-error { border-color: rgba(248, 113, 113, 0.4); }
#history-list li.status-ok    { border-color: rgba(74, 222, 128, 0.3); }
#history-list li.empty {
  color: var(--fg-muted);
  text-align: center;
  font-style: italic;
}
