:root {
  color-scheme:light;
  --bg:#f5f6f8;
  --surface:#fff;
  --text:#18202b;
  --muted:#5d6878;
  --border:#dce1e8;
  --accent:#3157d5;
  --soft:#eaf0ff;
  --danger:#a33324;
  --shadow:0 12px 40px #18202b08
}
@media(prefers-color-scheme:dark) {
  :root:not([data-theme=light]) {
    color-scheme:dark;
    --bg:#101319;
    --surface:#191e27;
    --text:#ecf0f8;
    --muted:#a4afc1;
    --border:#303949;
    --accent:#99b0ff;
    --soft:#28334c;
    --danger:#ffb2a6;
    --shadow:0 12px 40px #0002
  }
}
:root[data-theme=dark] {
  color-scheme:dark;
  --bg:#101319;
  --surface:#191e27;
  --text:#ecf0f8;
  --muted:#a4afc1;
  --border:#303949;
  --accent:#99b0ff;
  --soft:#28334c;
  --danger:#ffb2a6;
  --shadow:0 12px 40px #0002
}
* {
  box-sizing:border-box
}
html {
  scroll-padding-top:24px
}
body {
  margin:0;
  background:var(--bg);
  color:var(--text);
  font:16px/1.55 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  overflow-wrap:anywhere
}
a {
  color:var(--accent)
}
header {
  display:flex;
  align-items:center;
  gap:16px;
  border-bottom:1px solid var(--border);
  padding:16px max(20px,env(safe-area-inset-left));
  background:var(--surface)
}
.brand {
  display:flex;
  align-items:center;
  gap:10px;
  color:var(--text);
  text-decoration:none;
  font-weight:750;
  letter-spacing:.06em;
  min-width:0
}
.brand .muted {
  font-size:12px;
  font-weight:400;
  letter-spacing:0
}
.mark {
  display:grid;
  place-items:center;
  width:32px;
  height:32px;
  background:var(--text);
  color:var(--bg);
  border-radius:10px
}
.theme-label {
  display:flex;
  align-items:center;
  gap:8px;
  margin-left:auto;
  font-size:13px
}
.theme-label select {
  padding:6px;
  min-height:36px
}
main {
  max-width:1240px;
  margin:auto;
  padding:28px 28px max(28px,env(safe-area-inset-bottom))
}
.muted,.hint,small {
  color:var(--muted)
}
.hint,small {
  font-size:13px
}
.eyebrow {
  font-size:11px;
  letter-spacing:.14em;
  font-weight:700;
  color:var(--muted)
}
h1 {
  font-size:clamp(27px,4vw,36px);
  line-height:1.15;
  letter-spacing:-.035em;
  margin:12px 0
}
h2 {
  font-size:20px
}
h3 {
  font-size:17px
}
p {
  margin:10px 0 18px
}
.page-title {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  margin:30px 0 24px
}
.page-title p {
  margin-bottom:0
}
.navigation {
  display:flex;
  gap:6px;
  overflow:auto;
  padding:6px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:14px;
  scrollbar-width:thin
}
.navigation button {
  white-space:nowrap;
  flex:1;
  background:transparent;
  color:var(--muted);
  border:0;
  margin:0
}
.navigation [aria-current=page] {
  background:var(--soft);
  color:var(--accent)
}
button,input,textarea,select {
  font:inherit
}
input,textarea,select {
  background:var(--surface);
  color:var(--text);
  border:1px solid var(--border);
  border-radius:10px;
  padding:12px;
  width:100%;
  min-width:0
}
textarea {
  resize:vertical
}
label {
  display:block;
  font-size:14px;
  font-weight:550
}
label>input,label>textarea,label>select {
  display:block;
  margin:7px 0 16px
}
button {
  min-height:44px;
  padding:10px 18px;
  border:1px solid var(--border);
  border-radius:10px;
  background:var(--soft);
  color:var(--accent);
  font-weight:600;
  cursor:pointer;
  max-width:100%;
  margin:6px 6px 6px 0
}
button:hover {
  filter:brightness(.94)
}
button:disabled {
  opacity:.5;
  cursor:wait
}
.primary {
  background:var(--accent);
  border-color:var(--accent);
  color:var(--bg)
}
.quiet {
  background:transparent;
  color:var(--text)
}
:focus-visible {
  outline:3px solid var(--accent);
  outline-offset:3px
}
.card,.composer-card,.upload-card,article,.original-card,aside {
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:16px;
  padding:22px;
  box-shadow:var(--shadow);
  min-width:0
}
.login-card {
  max-width:450px;
  margin:6vh auto
}
.login-card form {
  margin-top:26px
}
.login-card .primary {
  width:100%
}
.timeline {
  display:grid;
  gap:12px;
  margin-bottom:20px
}
.timeline:empty:before {
  content:'Здесь появятся сохранённые сообщения и файлы.';
  padding:36px 12px;
  text-align:center;
  color:var(--muted)
}
article p,pre {
  white-space:pre-wrap;
  overflow-wrap:anywhere
}
article p {
  margin:12px 0
}
article button {
  font-size:13px;
  background:transparent;
  padding:6px 10px
}
.composer-card {
  margin-top:24px
}
.composer-actions {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px
}
.text-link {
  font-size:14px
}
.source-grid {
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(0,1fr);
  gap:20px;
  margin-top:20px
}
.original-card {
  align-self:start
}
#imagePreview {
  display:block;
  width:100%;
  height:auto;
  max-height:70vh;
  object-fit:contain;
  border-radius:8px
}
#sourceDownload {
  display:block;
  margin:12px 0
}
.search-form {
  display:grid;
  grid-template-columns:minmax(0,2fr) minmax(0,1fr) auto;
  gap:12px;
  align-items:end
}
.search-form button {
  margin-bottom:16px
}
.search-form label {
  min-width:0
}
#memoryResults {
  display:grid;
  gap:12px;
  margin-top:20px
}
dl {
  display:grid;
  grid-template-columns:auto minmax(0,1fr);
  gap:7px 15px;
  font-size:14px
}
dt {
  color:var(--muted)
}
dd {
  margin:0
}
pre {
  max-height:350px;
  overflow:auto;
  font:12px/1.6 ui-monospace,monospace;
  background:var(--bg);
  padding:16px;
  border-radius:8px
}
details {
  margin-top:20px
}
summary {
  cursor:pointer;
  color:var(--muted);
  font-size:13px
}
.notice:empty {
  display:none
}
.notice {
  position:sticky;
  bottom:16px;
  background:var(--surface);
  border:1px solid var(--border);
  border-left:4px solid var(--accent);
  padding:12px 16px;
  border-radius:10px;
  box-shadow:var(--shadow);
  white-space:pre-wrap
}
.connection {
  background:var(--soft);
  padding:12px;
  border-radius:10px
}
.skip {
  position:absolute;
  top:-100px
}
.skip:focus {
  top:10px;
  z-index:10;
  background:var(--surface);
  padding:12px
}
[hidden] {
  display:none!important
}
@media(max-width:700px) {
  header {
    flex-wrap:wrap;
    gap:10px;
    padding:12px 16px
  }
  .brand .muted {
    display:none
  }
  .theme-label {
    font-size:0
  }
  .theme-label select {
    font-size:13px;
    width:116px;
    margin:0
  }
  #logout {
    font-size:13px;
    padding:6px 10px
  }
  main {
    padding:18px 12px max(20px,env(safe-area-inset-bottom))
  }
  .navigation {
    gap:0;
    border-radius:12px
  }
  .navigation button {
    font-size:13px;
    padding:9px 12px
  }
  .page-title {
    margin:24px 2px 18px
  }
  .source-grid {
    grid-template-columns:1fr
  }
  .card,.composer-card,.upload-card,article,.original-card,aside {
    padding:16px;
    border-radius:12px
  }
  .search-form {
    grid-template-columns:minmax(0,1fr)
  }
  .search-form button {
    margin-top:0
  }
  .search-form label>input,.search-form label>select {
    margin-bottom:6px
  }
  input,textarea,select {
    font-size:16px
  }
  .login-card {
    margin:5vh 4px
  }
  dl {
    grid-template-columns:1fr
  }
  dd {
    margin-bottom:6px
  }
  .composer-card textarea {
    max-height:35dvh
  }
}
audio {
  display:block;
  width:100%;
  max-width:100%;
  margin:14px 0
}
.record-actions {
  display:flex;
  flex-wrap:wrap;
  gap:6px
}
#voiceComposer {
  border-top:1px solid var(--border);
  margin-top:20px;
  padding-top:10px
}
.page-title>div {
  min-width: 0;
  flex: 1;
}
.page-title>button {
  flex-shrink: 0;
  white-space: nowrap;
}
.navigation {
  scrollbar-width: none;
}
.navigation::-webkit-scrollbar {
  display: none;
}
/* REV3: application shell, reachable composer, bottom navigation and voice sheet. */
body{height:100dvh;overflow:hidden}header{height:68px;padding-block:10px}main{height:calc(100dvh - 68px);max-width:none;padding:0;position:relative}
#workspace{height:100%;display:grid;grid-template-columns:188px minmax(0,1fr);gap:0}
.navigation{grid-column:1;grid-row:1;display:flex;flex-direction:column;border-radius:0;border:0;border-right:1px solid var(--border);padding:20px 10px;overflow:auto;gap:8px}
.navigation button{display:flex;align-items:center;gap:12px;flex:0;text-align:left;font-size:14px;padding:12px;margin:0}.navigation button>span:first-child{font-size:24px;line-height:1}
[data-screen]{grid-column:2;grid-row:1;overflow:auto;overscroll-behavior:contain;min-height:0;padding:22px max(24px,calc((100% - 1000px)/2));scroll-padding-bottom:180px}
[data-screen=dialogue]{padding-bottom:190px}.page-title{margin:8px 0 20px}.page-title h1{font-size:28px}.page-title .eyebrow,.page-title p{display:none}
.composer-card{position:absolute;z-index:4;bottom:0;left:188px;right:0;margin:0;border-radius:18px 18px 0 0;padding:12px 24px;background:var(--surface);box-shadow:0 -8px 28px #0001;display:flex;align-items:center;gap:12px}
#composer{flex:1;min-width:0;display:flex;align-items:center;gap:10px;flex-wrap:wrap}#composer>label{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}#composer textarea{flex:1;min-width:130px;height:48px;max-height:120px;resize:vertical;margin:0}.composer-actions{gap:10px}.composer-actions button{margin:0}.mic-launch{border-radius:50px;font-size:20px;padding:10px 16px;flex-shrink:0}.mic-launch span{font-size:13px}
#voiceComposer{position:fixed;z-index:20;inset:8vh max(20px,calc((100vw - 600px)/2));background:var(--surface);border:1px solid var(--border);border-radius:24px;padding:24px;overflow:auto;margin:0;box-shadow:0 0 0 100vmax #0008}#closeVoice{float:right}.voice-live{display:flex;justify-content:space-between;align-items:center;gap:20px;margin:20px 0;font:28px ui-monospace,monospace}.voice-live meter{width:50%;height:12px}.live-draft{min-height:120px;padding:20px;background:var(--bg);border-radius:16px;font-size:20px;white-space:pre-wrap;overflow-wrap:anywhere}#record{border-radius:40px;min-height:64px;padding:16px 26px;font-size:19px}.record-actions{margin:20px 0}#audioForm{border-top:1px solid var(--border);padding-top:16px;margin-top:20px}#audioForm label{font-size:13px}.audio-player{display:flex;flex-wrap:wrap;gap:10px;align-items:center;padding:14px;border-radius:14px;border:1px solid var(--border);background:var(--bg)}.audio-player button{margin:0}.audio-player input{flex:1;min-width:80px;width:auto;padding:0;accent-color:var(--accent)}.audio-player span{font:12px ui-monospace,monospace}audio{display:none!important}
#notice{position:fixed;z-index:30;bottom:158px;left:max(20px,calc((100vw - 600px)/2));right:max(20px,calc((100vw - 600px)/2));max-height:20dvh;overflow:auto;font-size:14px}#connection{position:fixed;z-index:31;top:70px;left:20px;right:20px}#jobProgress:not(:empty){padding:12px;background:var(--soft);border-radius:12px;margin-bottom:16px}.login-card{max-height:calc(100dvh - 110px);overflow:auto;padding:24px;margin:20px auto}.login-card #passkeyLogin{width:100%;margin:20px 0 4px}.fallback summary{font-size:15px;color:var(--text)}
@media(max-width:700px){
 header{height:60px;flex-wrap:nowrap;gap:8px;padding:8px 12px}.brand{font-size:14px}.mark{width:28px;height:28px}.theme-label select{width:90px;font-size:12px}#logout{font-size:12px;min-height:36px}main{height:calc(100dvh - 60px)}#workspace{display:block;position:relative}
 .navigation{position:absolute;z-index:5;bottom:0;left:0;right:0;flex-direction:row;padding:4px 3px max(5px,env(safe-area-inset-bottom));border:0;border-top:1px solid var(--border);gap:0;overflow:hidden;border-radius:0}.navigation button{flex:1;display:flex;flex-direction:column;gap:1px;text-align:center;justify-content:center;align-items:center;font-size:10px;min-width:0;padding:4px 1px;line-height:1.4;min-height:52px;border-radius:10px}.navigation button>span:first-child{font-size:23px}
 [data-screen]{height:100%;padding:16px 12px calc(80px + env(safe-area-inset-bottom));scroll-padding-bottom:220px}[data-screen=dialogue]{padding-bottom:calc(220px + env(safe-area-inset-bottom))}.page-title h1{font-size:24px}.page-title{margin:0 2px 14px}.page-title>button{font-size:12px;padding:6px 10px;min-height:36px}
 .composer-card{left:0;bottom:calc(61px + env(safe-area-inset-bottom));padding:8px 10px;gap:6px;border-radius:16px 16px 0 0}#composer{gap:6px}#composer textarea{width:100%;flex-basis:100%;font-size:16px;height:44px;min-height:44px}.composer-actions{width:100%;justify-content:space-between}.composer-actions button{min-height:36px;padding:6px 14px;font-size:13px}.mic-launch{align-self:flex-start;min-height:48px;padding:9px 11px;margin:0}.mic-launch span{display:block;font-size:10px}#voiceComposer{inset:0;border-radius:0;padding:18px 16px calc(22px + env(safe-area-inset-bottom));height:100dvh;border:0}.voice-live{margin:16px 0}.live-draft{min-height:25dvh;font-size:19px}#notice{bottom:calc(210px + env(safe-area-inset-bottom));left:12px;right:12px;font-size:13px}.login-card{margin:0;padding:28px 20px;max-height:100%;height:100%}#voiceComposer h2{padding-top:12px}#closeVoice{margin:0 0 12px 10px}
}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;animation:none!important;transition:none!important}}
[data-screen]{padding-bottom:190px}@media(max-width:700px){[data-screen]{padding-bottom:calc(220px + env(safe-area-inset-bottom))}}
#uploadProgress{position:fixed;z-index:32;bottom:155px;left:20px;width:calc(100% - 40px);height:6px;accent-color:var(--accent)}
body{height:var(--app-height,100dvh)}main{height:calc(var(--app-height,100dvh) - 68px)}@media(max-width:700px){main{height:calc(var(--app-height,100dvh) - 60px)}#voiceComposer{height:var(--app-height,100dvh)}}
