/* Claude Chat — тёплая «глиняная» палитра. Подпись интерфейса: медный спарк ✳ + сериф. */
:root {
  --accent: #c96442;
  --accent-hover: #b5563a;
  --accent-soft: rgba(201, 100, 66, .12);
  --radius: 14px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.06);
  font-size: 16px;
}
[data-theme="dark"] {
  --bg: #1c1b17;
  --bg-side: #16150f;
  --surface: #262521;
  --surface-2: #2f2e27;
  --surface-3: #383730;
  --border: #3a382f;
  --border-soft: #302e26;
  --text: #ece9e0;
  --text-dim: #a5a091;
  --user-bubble: #33312a;
  --code-bg: #141310;
  --shadow-pop: 0 8px 32px rgba(0,0,0,.45);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #faf9f5;
  --bg-side: #f1efe7;
  --surface: #ffffff;
  --surface-2: #f2f0e9;
  --surface-3: #e9e6db;
  --border: #ddd8cc;
  --border-soft: #e8e4d9;
  --text: #2b2a25;
  --text-dim: #7d7869;
  --user-bubble: #edeade;
  --code-bg: #f4f2ec;
  --shadow-pop: 0 8px 32px rgba(60,50,30,.16);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.serif, .brand, .greeting h1, .proj-header h1, .login-title { font-family: "Iowan Old Style", Georgia, "Times New Roman", serif; }
.spark { color: var(--accent); }
button { font: inherit; cursor: pointer; color: inherit; }
textarea, input {
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: .55rem .8rem; width: 100%;
}
textarea::placeholder, input::placeholder { color: var(--text-dim); opacity: .75; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
textarea:focus-visible, input:focus-visible { outline-offset: 0; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- кнопки ---------- */
.btn-primary {
  background: var(--accent); color: #fff; border: 0;
  border-radius: 10px; padding: .6rem 1rem; font-weight: 600;
  transition: background .15s ease, transform .05s ease;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-ghost {
  background: none; border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: .45rem .9rem;
  transition: background .15s ease, border-color .15s ease;
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-small { padding: .25rem .7rem; font-size: .85rem; }
.icon-btn {
  background: none; border: 0; color: var(--text-dim);
  border-radius: 8px; padding: .35rem .45rem; line-height: 0;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- вход ---------- */
.login-body { display: grid; place-items: center; padding: 1rem; background:
  radial-gradient(60rem 40rem at 70% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.login-card {
  width: min(24rem, 100%); background: var(--surface);
  border: 1px solid var(--border-soft); border-radius: 18px;
  padding: 2.4rem 2.1rem; text-align: center; box-shadow: var(--shadow-pop);
}
.login-card .spark { font-size: 2.1rem; display: inline-block; animation: breathe 4s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.12); opacity: 1; } }
.login-title { font-weight: 500; font-size: 1.5rem; margin: .5rem 0 .2rem; }
.login-sub { color: var(--text-dim); font-size: .9rem; margin-bottom: 1.6rem; }
.login-card form { display: grid; gap: 1rem; text-align: left; }
.form-error { color: #d4573b; font-size: .88rem; }

.field { display: grid; gap: .35rem; font-size: .82rem; color: var(--text-dim); }
.field input, .field textarea { font-size: 1rem; color: var(--text); }

/* ---------- каркас ---------- */
.app { display: flex; height: 100dvh; }
.sidebar {
  width: 272px; flex: 0 0 auto; background: var(--bg-side);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; min-height: 0;
}
.side-top { padding: 1.1rem 1rem .4rem; display: grid; gap: 1rem; }
.brand { font-size: 1.02rem; letter-spacing: .01em; }
.btn-new { width: 100%; display: flex; align-items: center; justify-content: center; gap: .4rem; }
.btn-new .plus { font-size: 1.1rem; line-height: 1; }
.side-scroll { flex: 1; overflow-y: auto; padding: 0 .6rem 1rem; }
.side-section { margin-top: 1.1rem; }
.side-head, .group-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 .45rem .35rem; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .09em; color: var(--text-dim); font-weight: 600;
}
.group-head { margin-top: .9rem; }
.side-list { list-style: none; padding: 0; display: grid; gap: 1px; }
.side-list li { display: flex; align-items: center; border-radius: 9px; position: relative; }
.side-list li:hover, .side-list li:focus-within { background: var(--surface-2); }
.side-list li.active { background: var(--surface-2); }
.side-list li.active .item-btn { color: var(--accent); font-weight: 600; }
.side-list .item-btn {
  flex: 1; text-align: left; background: none; border: 0; color: var(--text);
  padding: .45rem .55rem; border-radius: 9px; font-size: .92rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.side-list .item-del {
  position: absolute; right: .2rem; opacity: 0;
  background: var(--surface-2);
}
.side-list li:hover .item-del, .side-list .item-del:focus-visible { opacity: 1; }
.side-list li:hover .item-btn, .side-list li:focus-within .item-btn { padding-right: 1.9rem; }
.side-list .proj-icon { margin-right: .4rem; color: var(--accent); font-size: .8em; }
.side-list .item-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-list .item-sub {
  display: block; font-size: .74rem; color: var(--text-dim); margin-top: .05rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-list .item-sub .proj-icon { margin-right: .25rem; }
.side-list.plain li { border-bottom: 1px solid var(--border-soft); border-radius: 0; }
.side-list.plain li:last-child { border-bottom: 0; }

.side-bottom {
  border-top: 1px solid var(--border-soft); padding: .65rem 1rem;
  display: flex; align-items: center; gap: .55rem;
}
.avatar {
  width: 1.7rem; height: 1.7rem; border-radius: 50%; flex: 0 0 auto;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: .8rem; font-weight: 700;
}
.user-name { flex: 1; font-size: .9rem; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.burger { display: none; position: absolute; top: .65rem; left: .65rem; z-index: 5; }
.backdrop { display: none; }

/* ---------- пустое состояние ---------- */
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view[hidden] { display: none; }
.empty-view { justify-content: center; align-items: center; padding: 2rem 1.2rem; }
.greeting { text-align: center; max-width: 36rem; animation: rise .45s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.greeting .spark.big { font-size: 2.7rem; display: inline-block; }
.greeting h1 { font-weight: 500; font-size: clamp(1.7rem, 4vw, 2.4rem); margin: .55rem 0 .6rem; letter-spacing: -.01em; }
.greeting-sub { color: var(--text-dim); max-width: 30rem; margin: 0 auto; }
.starters { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: 1.5rem; }
.starter {
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 99px; padding: .4rem .95rem; font-size: .88rem;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.starter:hover { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

/* ---------- чат ---------- */
.chat-header {
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem 1rem .7rem 3.1rem; border-bottom: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(6px);
}
.chat-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-proj {
  font-size: .78rem; color: var(--accent); background: none;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 99px; padding: .08rem .6rem; white-space: nowrap;
}
.chat-proj:hover { background: var(--accent-soft); }
.chat-header .icon-btn:last-child { margin-left: auto; }
.rename-input {
  font: inherit; padding: .1rem .45rem; border-radius: 7px; width: min(24rem, 60vw);
}
.proj-header .rename-input { font-size: 1.3rem; }

.chat-body { flex: 1; min-height: 0; display: flex; position: relative; }
.messages { flex: 1; overflow-y: auto; padding: 1.4rem 1.2rem 0; scroll-behavior: smooth; }

/* панель файлов workspace */
.fs-drawer {
  width: 300px; flex: 0 0 auto; border-left: 1px solid var(--border-soft);
  background: var(--bg-side); display: flex; flex-direction: column; min-height: 0;
}
.fs-drawer[hidden] { display: none; }
.fs-head {
  display: flex; align-items: center; gap: .2rem;
  padding: .65rem .8rem .4rem; font-weight: 600; font-size: .92rem;
}
.fs-head span { flex: 1; }
.fs-crumbs {
  padding: 0 .8rem .45rem; font-size: .78rem; color: var(--text-dim);
  border-bottom: 1px solid var(--border-soft); overflow-x: auto; white-space: nowrap;
}
.fs-crumbs button {
  background: none; border: 0; color: var(--accent); padding: 0; font-size: inherit;
}
.fs-crumbs button:hover { text-decoration: underline; }
.fs-toolbar {
  display: flex; gap: .4rem; padding: .5rem .8rem 0;
}
.fs-list { list-style: none; padding: .4rem .5rem; margin: 0; overflow-y: auto; flex: 1; }
.move-list { display: grid; gap: 2px; max-height: 40vh; overflow-y: auto; }
.move-opt {
  display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem;
  border-radius: 8px; font-size: .92rem; cursor: pointer;
}
.move-opt:hover { background: var(--surface-2); }
.move-opt input { width: auto; accent-color: var(--accent); }
.fs-list li {
  display: flex; align-items: center; gap: .45rem;
  padding: .32rem .4rem; border-radius: 8px; font-size: .88rem; min-width: 0;
}
.fs-list li:hover { background: var(--surface-2); }
.fs-ico { color: var(--text-dim); flex: 0 0 auto; }
.fs-name {
  background: none; border: 0; color: var(--text); padding: 0; text-align: left;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1;
}
button.fs-name { cursor: pointer; }
button.fs-name:hover { color: var(--accent); }
.fs-list .size { color: var(--text-dim); font-size: .74rem; flex: 0 0 auto; }
.fs-acts { display: none; gap: 0; flex: 0 0 auto; }
.fs-list li:hover .fs-acts, .fs-list li:focus-within .fs-acts { display: inline-flex; }
.fs-acts .icon-btn { padding: .1rem .3rem; font-size: .85rem; text-decoration: none; }
.fs-empty { padding: .8rem; }
.fs-usage {
  border-top: 1px solid var(--border-soft); padding: .55rem .8rem .7rem;
  font-size: .74rem; color: var(--text-dim); display: grid; gap: .35rem;
}
.usage-bar { height: 4px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.usage-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s ease; }
.usage-fill.over { background: #d4573b; }
.fs-drawer .rename-input { width: 100%; font-size: .88rem; padding: .05rem .35rem; }
@media (prefers-reduced-motion: reduce) { .messages { scroll-behavior: auto; } }
.msg { max-width: 44rem; margin: 0 auto 1.4rem; animation: rise .25s ease both; }

.msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.msg-user .bubble {
  background: var(--user-bubble); border-radius: 16px 16px 4px 16px;
  padding: .65rem 1rem; max-width: 85%;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg .attach-note { font-size: .78rem; color: var(--text-dim); margin-top: .3rem; }

.msg-assistant { display: grid; grid-template-columns: 1.9rem 1fr; gap: .65rem; }
.msg-assistant .ava {
  width: 1.9rem; height: 1.9rem; border-radius: 50%; margin-top: .1rem;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: .95rem; user-select: none;
}
.msg-assistant.streaming .ava { animation: breathe 1.6s ease-in-out infinite; }
.msg-assistant .body { min-width: 0; padding-top: .15rem; overflow-wrap: anywhere; }
.msg-actions { margin-top: .35rem; display: flex; gap: .2rem; opacity: 0; transition: opacity .15s ease; }
.msg-assistant:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-actions .icon-btn { font-size: .78rem; padding: .2rem .5rem; line-height: 1.2; }

.tool-note {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .8rem; color: var(--text-dim);
  border: 1px solid var(--border-soft); background: var(--surface);
  border-radius: 99px; padding: .12rem .7rem; margin: .3rem 0;
}
.tool-note.spin::before {
  content: ""; width: .7rem; height: .7rem; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: rot .8s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .tool-note.spin::before, .msg-assistant.streaming .ava, .login-card .spark { animation: none; }
}
.typing { display: inline-flex; gap: .25rem; padding: .4rem 0; }
.typing i {
  width: .38rem; height: .38rem; border-radius: 50%; background: var(--text-dim);
  animation: blink 1.2s ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%,70%,100% { opacity: .25; } 35% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; opacity: .6; } }

/* markdown */
.md > * + * { margin-top: .7rem; }
.md ul, .md ol { padding-left: 1.4rem; }
.md li + li { margin-top: .25rem; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.3; margin-top: 1.1rem; font-size: 1.05rem; }
.md h1 { font-size: 1.25rem; } .md h2 { font-size: 1.15rem; }
.md code {
  background: var(--code-bg); border: 1px solid var(--border-soft);
  border-radius: 5px; padding: .08rem .35rem; font-size: .86em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.md pre {
  background: var(--code-bg); border: 1px solid var(--border-soft);
  border-radius: 12px; padding: .85rem 1rem; overflow-x: auto; position: relative;
}
.md pre code { background: none; border: 0; padding: 0; font-size: .85rem; }
.md pre .code-copy {
  position: absolute; top: .4rem; right: .4rem; opacity: 0;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 7px; font-size: .72rem; padding: .15rem .5rem; color: var(--text-dim);
}
.md pre:hover .code-copy, .md pre .code-copy:focus-visible { opacity: 1; }
.md blockquote { border-left: 3px solid var(--accent); padding-left: .85rem; color: var(--text-dim); }
.md table { border-collapse: collapse; display: block; overflow-x: auto; font-size: .92rem; }
.md th, .md td { border: 1px solid var(--border); padding: .35rem .65rem; }
.md th { background: var(--surface-2); }
.md a { color: var(--accent); }
.md hr { border: 0; border-top: 1px solid var(--border); }

/* ---------- композер ---------- */
.composer-zone { padding: .4rem 1.2rem 1rem; }
.attach-chips { max-width: 44rem; margin: 0 auto .35rem; display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  font-size: .8rem; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 99px; padding: .12rem .35rem .12rem .65rem;
  display: inline-flex; gap: .3rem; align-items: center; max-width: 16rem;
}
.chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { background: none; border: 0; color: var(--text-dim); padding: 0 .25rem; border-radius: 50%; }
.chip button:hover { color: var(--text); }
.composer {
  max-width: 44rem; margin: 0 auto; display: flex; align-items: flex-end; gap: .35rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; padding: .5rem .5rem .5rem .55rem;
  box-shadow: var(--shadow-1), 0 4px 20px rgba(0,0,0,.07);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer .attach { align-self: flex-end; margin-bottom: .12rem; }
.composer textarea {
  border: 0; background: none; resize: none; max-height: 12rem;
  padding: .35rem .2rem; line-height: 1.5;
}
.composer textarea:focus-visible { outline: none; }
.send-btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 50%;
  width: 2.2rem; height: 2.2rem; flex: 0 0 auto;
  display: grid; place-items: center; transition: background .15s ease, transform .05s ease;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { background: var(--surface-3); color: var(--text-dim); cursor: default; }
.send-btn .ic-stop { display: none; }
.send-btn.stop .ic-stop { display: block; }
.send-btn.stop .ic-send { display: none; }
.send-btn.stop { background: var(--text); color: var(--bg); }
.composer-hint {
  max-width: 44rem; margin: .4rem auto 0; font-size: .72rem;
  color: var(--text-dim); text-align: center; opacity: .8;
}

/* drag&drop */
.drop-overlay {
  position: absolute; inset: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
}
.drop-overlay[hidden] { display: none; }
.drop-inner {
  border: 2px dashed var(--accent); color: var(--accent);
  border-radius: var(--radius); padding: 2rem 3rem; font-weight: 600;
  background: var(--surface);
}

/* ---------- проект ---------- */
.project-view { overflow-y: auto; }
.proj-wrap { max-width: 44rem; margin: 0 auto; padding: 2.6rem 1.2rem 3rem; width: 100%; display: grid; gap: 1.1rem; }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); font-weight: 700; }
.proj-header { display: flex; align-items: center; gap: .8rem; margin-top: -0.6rem; }
.proj-header h1 { font-weight: 500; font-size: 1.7rem; flex: 1; letter-spacing: -.01em; }
.proj-actions { display: flex; gap: .4rem; align-items: center; }
.proj-card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 1.1rem; display: grid; gap: .8rem;
}
.card-head { display: flex; justify-content: space-between; align-items: center;
  font-size: .82rem; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .07em; }
.btn-save { justify-self: end; }
.hint-empty { color: var(--text-dim); font-size: .85rem; }
.file-list { list-style: none; padding: 0; display: grid; }
.file-list li {
  display: flex; align-items: center; gap: .6rem; padding: .45rem .3rem;
  font-size: .92rem; border-bottom: 1px solid var(--border-soft);
}
.file-list li:last-child { border-bottom: 0; }
.file-list .fi { color: var(--text-dim); flex: 0 0 auto; }
.file-list .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .size { color: var(--text-dim); font-size: .78rem; margin-left: auto; flex: 0 0 auto; }

/* ---------- модалка ---------- */
dialog {
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--text); padding: 1.5rem;
  width: min(26rem, 92vw); box-shadow: var(--shadow-pop);
}
dialog::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(2px); }
.dialog-form { display: grid; gap: 1rem; }
.dialog-form h2 { font-size: 1.15rem; font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; }

/* ---------- мобильный ---------- */
@media (max-width: 760px) {
  .burger { display: block; background: var(--surface); border: 1px solid var(--border-soft); }
  .backdrop {
    display: block; position: fixed; inset: 0; z-index: 9;
    background: rgba(0,0,0,.45); opacity: 1; transition: opacity .2s ease;
  }
  .backdrop[hidden] { display: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 10; width: min(20rem, 84vw);
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: none;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-pop); }
  @media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
  .chat-header { padding-left: 3.1rem; }
  .messages { padding: 1.2rem .9rem 0; }
  .fs-drawer {
    position: absolute; inset: 0 0 0 auto; z-index: 8;
    width: min(19rem, 88vw); box-shadow: var(--shadow-pop);
  }
  .composer-zone { padding: .4rem .8rem .8rem; }
  .composer-hint { display: none; }
  .msg-actions { opacity: 1; }
  .side-list .item-del { opacity: 1; }
}
