:root {
  --bg: #f4f6fb; --card: #fff; --text: #1d2433; --muted: #6b7489; --line: #e3e7f0;
  --blue: #2f6fed; --blue-soft: #e8efff; --green: #1f9d55; --green-soft: #e6f6ec;
  --orange: #d97706; --orange-soft: #fff3e0; --red: #d64545; --red-soft: #fdecec;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
#app { max-width: 640px; margin: 0 auto; padding: 16px 14px calc(32px + env(safe-area-inset-bottom)); }
a { color: var(--blue); word-break: break-word; }
.center { text-align: center; padding: 40px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 14px; gap: 8px; }
.top h1 { font-size: 24px; margin: 0; }
.ai-note { font-size: 13px; color: var(--muted); margin: -6px 2px 14px; }
.btn { text-decoration: none; appearance: none; border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600;
  background: var(--blue); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:disabled { opacity: .55; }
.btn.light { background: var(--blue-soft); color: var(--blue); }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 500; padding: 8px 10px; }
.btn.green { background: var(--green); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.group h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 4px 8px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(20, 30, 60, .06); border: 1px solid var(--line); }
a.card { display: block; text-decoration: none; color: inherit; }
.card .subj { font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.card .txt { margin-top: 4px; color: #3a4357; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.st-new { background: var(--red-soft); color: var(--red); }
.st-checking { background: var(--blue-soft); color: var(--blue); }
.st-needs_fix { background: var(--orange-soft); color: var(--orange); }
.st-done, .st-self_done { background: var(--green-soft); color: var(--green); }
.empty { padding: 14px 16px; color: var(--muted); background: var(--card); border-radius: var(--radius); border: 1px dashed var(--line); }
.footer { margin-top: 22px; text-align: center; color: var(--muted); font-size: 13px; }

.back { margin: 0 0 8px -6px; }
.task-head h1 { font-size: 22px; margin: 4px 0 6px; }
.task-text { font-size: 17px; white-space: pre-wrap; }
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--blue); font-weight: 600; }
.lesson { white-space: pre-wrap; color: #3a4357; margin-top: 8px; }
.links a { display: block; margin-top: 6px; }
.actions { display: grid; gap: 10px; margin: 16px 0; }
.result { border-left: 5px solid var(--orange); }
.result.ok { border-left-color: var(--green); }
.problems { margin: 8px 0 0; padding-left: 18px; }
.problems li { margin-bottom: 6px; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumbs img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

.chat { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.msg { max-width: 88%; padding: 10px 12px; border-radius: 14px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.composer { display: flex; gap: 8px; margin-top: 10px; }
.composer textarea, .input { flex: 1; font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 12px; resize: none; background: #fff; }
.pin { font-size: 28px; letter-spacing: .4em; text-align: center; width: 100%; }
.spinner { width: 18px; height: 18px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
.spinner.dark { border-color: rgba(47,111,237,.25); border-top-color: var(--blue); }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { background: var(--blue-soft); color: #23408f; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.error { background: var(--red-soft); color: var(--red); border-radius: 12px; padding: 10px 12px; margin: 10px 0; }
.problems .why { margin-top: 4px; }
.problems .ask { margin-top: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.chip { appearance: none; border: 0; background: var(--blue-soft); color: var(--blue); border-radius: 999px;
  padding: 7px 12px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.msgimg { display: block; max-width: 180px; border-radius: 10px; margin-bottom: 6px; }
.et { color: #2c6e49; margin-top: 3px; }
.et::before { content: "🇪🇪 "; }
.msg.assistant .et { border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 6px; }
.ai-note .et, .small .et { color: var(--muted); font-style: italic; }
.ai-note .et::before, .small .et::before { content: ""; }
.hintline { margin-top: 4px; color: #3a4357; }
.problems .why .ru, .problems .hintline .ru { display: inline; }
.problems li > .ru { display: inline; }
