@font-face {
  font-family: "Golos Text";
  src: url("/golos-regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Golos Text";
  src: url("/golos-semibold.ttf") format("truetype");
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: "Golos Text", system-ui, sans-serif;
  color: #202239;
  background: #fafaff;
  --surface: #fff;
  --rail: #f0f0f8;
  --line: #e3e3ef;
  --muted: #656781;
  --accent: #503cdd;
  --accent-dark: #3d2cbd;
  --accent-soft: #e9e5ff;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 20rem; }
button, select, input, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled, select:disabled { cursor: default; opacity: .48; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.layout {
  display: grid;
  grid-template-columns: clamp(12.5rem, 19vw, 15.5rem) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--rail); border-right: 1px solid var(--line); padding: 1.4rem 1rem; }
.sidebar-top { display: flex; flex-direction: column; gap: 1.85rem; }
.brand { display: flex; align-items: center; gap: .65rem; width: fit-content; padding-inline: .25rem; }
.brand strong { font-size: 1.25rem; letter-spacing: -.05em; }
.mark { display: grid; place-items: center; position: relative; width: 2.25rem; height: 2.25rem; padding-right: .18rem; padding-bottom: .15rem; color: #fff; background: #262146; border-radius: .65rem; font-size: 1.22rem; font-weight: 700; line-height: 1; }
.mark span { position: absolute; left: 1.29rem; top: .69rem; color: #b6a9ff; }
.new-project, .quiet, .primary { display: inline-flex; align-items: center; justify-content: center; gap: .48rem; min-height: 2.55rem; padding: .5rem .85rem; border: 1px solid transparent; border-radius: .65rem; font-size: .9rem; font-weight: 600; white-space: nowrap; }
.new-project { justify-content: flex-start; background: var(--surface); color: #282448; border-color: #deddee; }
.new-project span { color: var(--accent); font-size: 1.35rem; line-height: .8; }
.new-project:hover:enabled { border-color: #bcb2f0; }
.quiet { color: var(--muted); background: transparent; padding-inline: .65rem; }
.quiet:hover:enabled { color: #23223b; background: var(--rail); }
.primary { background: var(--accent); color: #fff; padding-inline: 1rem; }
.primary:hover:enabled { background: var(--accent-dark); }

.project-list { min-height: 0; margin-top: 1.65rem; overflow: auto; }
.project-list h2 { margin: 0 0 .45rem; padding-inline: .57rem; font-size: .875rem; font-weight: 600; color: var(--muted); }
#projects { display: grid; gap: .18rem; }
#projects button { display: flex; align-items: center; gap: .6rem; width: 100%; min-width: 0; min-height: 2.4rem; border: 0; background: transparent; border-radius: .55rem; padding: .5rem .57rem; color: #464863; text-align: left; font-size: .9rem; }
#projects button::before { content: ""; flex: 0 0 auto; width: .68rem; height: .58rem; border: 1.4px solid currentColor; border-radius: .16rem; }
#projects button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#projects button:hover { background: #e9e9f4; }
#projects button[aria-current] { background: var(--accent-soft); color: #3f2aaf; font-weight: 600; }

.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .65rem; min-height: 4.2rem; padding: .7rem clamp(1rem, 3vw, 2rem); background: var(--surface); border-bottom: 1px solid var(--line); }
.project-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: .25rem; }
.connection { display: inline-flex; align-items: center; gap: .4rem; padding: .38rem .55rem; color: #266442; border-radius: .4rem; font-size: .875rem; white-space: nowrap; }
.connection::before { content: ""; width: .43rem; height: .43rem; border-radius: 50%; background: #29834e; }
.connection.offline { color: #8d393e; }
.connection.offline::before { background: #ac5156; }
.work-area { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.work-width { width: min(100%, 46rem); margin-inline: auto; }
.compose-area { padding: clamp(2.4rem, 13vh, 8rem) clamp(1rem, 4vw, 2.5rem) 2rem; }
#new-task-title { margin: 0 0 1.1rem; color: #211f3c; font-size: clamp(2rem, 4vw, 3.2rem); line-height: 1.08; letter-spacing: -.065em; }
.composer { border: 1px solid #dcd9ee; border-radius: 1.05rem; background: var(--surface); box-shadow: 0 4px 16px #2c235408; }
.composer:focus-within { border-color: #a99aee; box-shadow: 0 0 0 3px #503cdd15; }
.composer textarea { display: block; width: 100%; min-height: 5.4rem; max-height: 32vh; padding: 1rem 1.05rem .3rem; border: 0; color: inherit; outline: 0; border-radius: inherit; background: transparent; resize: vertical; font-size: 1.03rem; line-height: 1.6; }
textarea::placeholder { color: #70728c; opacity: 1; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: .65rem; padding: .6rem; }
#send-task { margin-left: auto; }
.model-picker { min-width: 0; }
.model-picker select { display: block; max-width: 100%; padding: .42rem .45rem; border: 0; border-radius: .4rem; color: #50506c; background: var(--rail); font-size: .875rem; text-overflow: ellipsis; }
.history-scroll { flex: 1; overflow: auto; padding: 1.8rem clamp(1rem, 4vw, 2.5rem); }
.history h1 { margin: 0 0 1.1rem; font-size: 1.55rem; line-height: 1.15; letter-spacing: -.045em; }
.has-history .compose-area { padding-block: .8rem 1.15rem; border-top: 1px solid var(--line); }
.has-history .composer textarea { min-height: 3.9rem; height: 4.25rem; }
.task-card { margin-bottom: .8rem; padding: 1rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--surface); overflow-wrap: anywhere; }
.task-head { display: flex; justify-content: space-between; align-items: start; gap: .65rem; margin-bottom: .5rem; }
.task-head h2 { margin: 0; font-size: 1rem; line-height: 1.45; white-space: pre-wrap; }
.task-status { flex: none; padding: .2rem .43rem; border-radius: .39rem; color: #4936a5; background: var(--accent-soft); font-size: .825rem; }
.task-status.done { color: #216442; background: #e8f4ec; }
.task-status.failed, .task-status.interrupted { color: #933c44; background: #fbebef; }
.task-meta { display: block; margin: 0; color: var(--muted); font-size: .81rem; }
.task-answer { margin: .8rem 0 0; padding-top: .8rem; border-top: 1px solid var(--line); white-space: pre-wrap; line-height: 1.6; }
.task-actions { display: flex; margin-top: .55rem; }
.task-actions .quiet { min-height: 2rem; padding-inline: .45rem; color: #4936a5; }
.feedback { margin: .65rem 0 0; color: #9a3443; font-size: .9rem; overflow-wrap: anywhere; }
.feedback.success { color: #276141; }

dialog { width: min(33rem, calc(100vw - 2rem)); margin: auto; padding: 1.35rem; border: 1px solid var(--line); border-radius: 1rem; color: inherit; background: var(--surface); box-shadow: 0 20px 65px #1f163f28; }
dialog::backdrop { background: #201b4266; }
dialog h2 { margin: 0 0 1rem; font-size: 1.4rem; letter-spacing: -.04em; }
dialog label:not(.sr-only) { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .875rem; }
dialog input, dialog textarea { width: 100%; padding: .65rem; border: 1px solid #dcd9ee; border-radius: .55rem; color: inherit; background: #fdfdff; line-height: 1.5; }
dialog textarea { resize: vertical; }
.dialog-actions { display: flex; justify-content: end; gap: .45rem; margin-top: .95rem; }
.login-page { display: grid; place-items: center; min-height: 100vh; min-height: 100svh; padding: 1rem; }
.login-card { width: min(100%, 24rem); padding: 1.55rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
.login-card .brand { margin: 0 0 1.3rem; padding: 0; }
#telegram-login { width: 100%; }
#login-status { margin: .65rem 0 0; color: var(--muted); font-size: .9rem; }
#login-status:empty { display: none; }

@media (max-width: 680px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: .65rem .8rem; }
  .sidebar-top { flex-direction: row; align-items: center; justify-content: space-between; gap: .65rem; }
  .project-list { margin-top: .5rem; }
  .project-list h2 { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  #projects { display: flex; gap: .3rem; overflow: auto; }
  #projects button { width: auto; max-width: min(70vw, 15rem); flex: 0 0 auto; min-height: 2rem; }
  .topbar { min-height: 3.3rem; padding: .35rem .8rem; }
  .topbar-actions { gap: .1rem; }
  .topbar-actions .quiet, .connection { padding-inline: .35rem; }
  .compose-area { padding-top: clamp(1.7rem, 8vh, 3.5rem); }
  .has-history .compose-area { padding-bottom: max(.65rem, env(safe-area-inset-bottom)); }
  .history-scroll { padding-top: 1.05rem; }
}

@media (max-width: 360px) {
  .topbar { gap: .35rem; }
  .connection { gap: .24rem; }
  .task-head { flex-wrap: wrap; }
}
