:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --border: #334155;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
body.centered { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
}
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 1.25rem; margin: 0 0 .25rem; }
.muted { color: var(--muted); font-size: .9rem; }

input[type="password"], input[type="text"], textarea {
  width: 100%; padding: .7rem .8rem; margin: .6rem 0;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 1rem;
}
button {
  cursor: pointer; border: none; border-radius: 8px;
  padding: .7rem 1rem; font-size: 1rem; color: #fff; background: var(--accent);
  transition: background .15s;
}
button:hover:not(:disabled) { background: var(--accent-2); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary { background: var(--panel-2); border: 1px solid var(--border); }
button.danger { background: var(--red); }
button.success { background: var(--green); }

.error { color: #fca5a5; font-size: .9rem; }

/* assistant layout */
.app-wrap { max-width: 780px; margin: 0 auto; padding: 1rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.topbar h1 { font-size: 1.2rem; margin: 0; }

.controls { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.controls-side { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.orb-wrap { display: flex; flex-direction: column; align-items: center; gap: .5rem; }

/* Flat, minimal voice button */
.mic-orb {
  position: relative; width: 96px; height: 96px; border-radius: 50%;
  background: #161d2b; border: 1px solid #28344a;
  display: flex; align-items: center; justify-content: center;
  padding: 0; cursor: pointer; user-select: none; -webkit-user-select: none;
  touch-action: manipulation; transition: background .2s, border-color .2s, box-shadow .2s;
}
.mic-orb:hover { border-color: #38496a; }
.mic-orb:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
/* Active (mic on): subtle accent, soft ring */
.mic-orb.active {
  background: #0d1f33; border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}
.mic-orb.connecting { opacity: .8; }
.mic-orb.connecting .wave .bar { animation: bar-idle 1s ease-in-out infinite; }

/* Voice wave: five flat bars */
.wave { display: flex; align-items: center; gap: 5px; height: 36px; }
.wave .bar {
  width: 4px; height: 8px; border-radius: 2px; background: #6b7a93;
  transition: height .09s ease-out, background .2s;
}
.mic-orb.active .wave .bar { background: var(--accent); }
.wave .bar:nth-child(1) { animation-delay: 0s; }
.wave .bar:nth-child(2) { animation-delay: .12s; }
.wave .bar:nth-child(3) { animation-delay: .24s; }
.wave .bar:nth-child(4) { animation-delay: .12s; }
.wave .bar:nth-child(5) { animation-delay: 0s; }
@keyframes bar-idle { 0%, 100% { height: 8px; } 50% { height: 20px; } }

.orb-hint { font-size: .8rem; color: var(--muted); }

.status-pill {
  padding: .4rem .8rem; border-radius: 999px; font-size: .85rem;
  background: var(--panel-2); border: 1px solid var(--border);
}
.status-pill[data-state="слушаю"] { border-color: var(--green); color: #86efac; }
.status-pill[data-state="думаю"] { border-color: var(--amber); color: #fcd34d; }
.status-pill[data-state="отвечаю"] { border-color: var(--accent); color: #93c5fd; }
.status-pill[data-state="ошибка"] { border-color: var(--red); color: #fca5a5; }

.tech-status { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); margin-bottom: 1rem; flex-wrap: wrap; }
.tech-status .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .35rem; background: var(--muted); }
.tech-status .dot.ok { background: var(--green); }
.tech-status .dot.bad { background: var(--red); }

.pending {
  background: #422006; border: 1px solid var(--amber);
  border-radius: 12px; padding: 1rem; margin-bottom: 1rem;
}
.pending h3 { margin: 0 0 .5rem; font-size: 1rem; color: #fcd34d; }
.pending .actions { display: flex; gap: .6rem; margin-top: .8rem; }

.last-task {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1rem; font-size: .9rem;
}
.last-task .label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }

.composer {
  display: flex; gap: .5rem; align-items: center;
  position: sticky; bottom: 0; z-index: 5;
  background: var(--bg); padding: .6rem 0 .2rem;
}
.composer input { flex: 1; margin: 0; }
.composer button { white-space: nowrap; }
.composer-hint { margin: .3rem 0 .6rem; font-size: .78rem; }
#mic-toggle.on { background: var(--green); color: #fff; border-color: var(--green); }

.dialogs-bar { display: flex; gap: .5rem; margin: .25rem 0 .5rem; }
.dialogs-bar button { font-size: .85rem; padding: .45rem .8rem; }
.dialogs-panel {
  border: 1px solid var(--border); border-radius: 10px; padding: .4rem;
  margin-bottom: .6rem; max-height: 220px; overflow-y: auto;
  display: flex; flex-direction: column; gap: .2rem;
}
.dialog-item {
  display: flex; justify-content: space-between; gap: .5rem; align-items: center;
  padding: .5rem .6rem; border-radius: 8px; cursor: pointer; background: transparent;
  border: none; color: var(--text); text-align: left; width: 100%; font-size: .9rem;
}
.dialog-item:hover { background: var(--panel-2); }
.dialog-item .d-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-item .d-meta { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.dialogs-empty { color: var(--muted); font-size: .85rem; padding: .5rem; }
.viewing-banner {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  background: #422006; border: 1px solid var(--amber); border-radius: 8px;
  padding: .5rem .7rem; margin-bottom: .6rem; font-size: .85rem; color: #fcd34d;
}

.history {
  display: flex; flex-direction: column; gap: .6rem; margin-top: .5rem;
  min-height: 120px; max-height: 60vh; overflow-y: auto;
  padding-right: .3rem;
}
.msg { padding: .7rem .9rem; border-radius: 10px; max-width: 90%; white-space: pre-wrap; }
.msg.user { background: var(--accent); align-self: flex-end; }
.msg.assistant { background: var(--panel-2); align-self: flex-start; border: 1px solid var(--border); }
.msg.system { background: transparent; color: var(--muted); font-size: .8rem; align-self: center; font-style: italic; }
.msg .who { font-size: .7rem; opacity: .7; margin-bottom: .2rem; }

a { color: #93c5fd; }
.section-title { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 1rem 0 .5rem; }
