:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #f3f5f8);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #17202d);
  --muted: var(--tg-theme-hint-color, #788496);
  --accent: var(--tg-theme-button-color, #3578e5);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--text) 11%, transparent);
  --soft: color-mix(in srgb, var(--accent) 9%, var(--card));
  --danger: #d64242;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; min-height: 100vh; background: var(--bg); }
button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
.loading-screen, .notice-screen { min-height: 72vh; display: grid; align-content: center; justify-items: center; gap: 12px; padding: 28px; text-align: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.shell { width: min(100%, 680px); min-height: 100vh; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px calc(94px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 2px 18px; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 15px; color: white; background: linear-gradient(140deg, #59a7ff, #336fe0); font-size: 22px; box-shadow: 0 6px 18px #3578e533; }
.brand h1 { font-size: 18px; line-height: 1.15; margin: 0; letter-spacing: -.3px; }
.brand p { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.icon-button { display: grid; place-items: center; min-width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: var(--card); font-size: 18px; }
.content { display: grid; gap: 13px; }
.welcome { padding: 20px; border-radius: 23px; color: #fff; background: radial-gradient(circle at 90% 5%, #ffffff38, transparent 37%), linear-gradient(140deg, #408ef0, #2462cb); box-shadow: 0 12px 28px #2462cb24; }
.welcome .eyebrow { margin: 0 0 8px; opacity: .84; font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
.welcome h2 { margin: 0; font-size: 22px; line-height: 1.2; }
.welcome p { margin: 9px 0 0; font-size: 14px; line-height: 1.5; opacity: .92; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 1px 0; }
.section-head h2 { margin: 0; font-size: 19px; letter-spacing: -.25px; }
.section-head p { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.card { padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 19px; box-shadow: 0 4px 16px #23304808; }
.request-card { display: grid; gap: 11px; cursor: pointer; transition: transform .15s ease; }
.request-card:active { transform: scale(.99); }
.request-top { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.request-number { font-weight: 750; font-size: 15px; }
.request-discipline { font-size: 14px; line-height: 1.4; }
.request-date { color: var(--muted); font-size: 12px; }
.status-pill { padding: 6px 9px; border-radius: 999px; color: #2462cb; background: var(--soft); font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-pill[data-status="completed"] { color: #138454; background: #1db9801a; }
.status-pill[data-status="cancelled"] { color: #bb4545; background: #d6424218; }
.status-pill[data-status="clarification"] { color: #a26a00; background: #f5b82e24; }
.empty-state { padding: 30px 20px; text-align: center; color: var(--muted); }
.empty-icon { width: 54px; height: 54px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 18px; background: var(--soft); font-size: 24px; }
.empty-state h3 { color: var(--text); margin: 0 0 6px; font-size: 16px; }
.empty-state p { margin: 0; font-size: 13px; line-height: 1.5; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 16px; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-text); font-weight: 680; cursor: pointer; transition: opacity .15s ease, transform .15s ease; }
.button:active { transform: scale(.98); }
.button:disabled { opacity: .55; cursor: wait; }
.button-secondary { color: var(--text); background: var(--soft); }
.button-danger { color: #fff; background: var(--danger); }
.button-quiet { min-height: 37px; padding: 0 11px; color: var(--accent); background: var(--soft); font-size: 13px; }
.button-full { width: 100%; }
.button-row { display: flex; gap: 9px; }
.button-row > * { flex: 1; }
.form-card { display: grid; gap: 16px; }
.form-progress { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.progress-segment { height: 4px; border-radius: 99px; background: var(--line); }
.progress-segment.active { background: var(--accent); }
.step-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.form-card h2 { margin: 0; font-size: 20px; line-height: 1.25; }
.field { display: grid; gap: 7px; }
.field label, .field-label { font-size: 13px; font-weight: 650; }
.field-hint { margin: -2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.text-input, .text-area, .select-input { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 13px; color: var(--text); background: var(--bg); outline: none; }
.text-area { min-height: 132px; resize: vertical; line-height: 1.5; }
.text-input:focus, .text-area:focus, .select-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.choice-list { display: grid; gap: 8px; }
.choice { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 51px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 15px; text-align: left; color: var(--text); background: var(--card); }
.choice.selected { border-color: var(--accent); background: var(--soft); }
.choice-check { display: grid; place-items: center; width: 21px; height: 21px; flex: 0 0 auto; border: 1.5px solid var(--muted); border-radius: 50%; color: white; font-size: 12px; }
.choice.selected .choice-check { border-color: var(--accent); background: var(--accent); }
.file-picker { display: grid; place-items: center; min-height: 100px; padding: 16px; border: 1.5px dashed color-mix(in srgb, var(--accent) 44%, var(--line)); border-radius: 16px; color: var(--accent); background: var(--soft); text-align: center; cursor: pointer; }
.file-picker input { display: none; }
.file-picker strong { display: block; margin-top: 5px; color: var(--text); font-size: 14px; }
.file-picker span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.file-list, .attachment-list { display: grid; gap: 7px; }
.file-item, .attachment-link { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 11px; border-radius: 12px; background: var(--bg); font-size: 13px; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remove-file { color: var(--danger); border: 0; background: transparent; padding: 5px; font-size: 18px; }
.summary-list { display: grid; gap: 11px; }
.summary-item { display: grid; gap: 4px; }
.summary-label { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.summary-value { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.summary-edit { margin-top: 3px; width: fit-content; min-height: 31px; }
.notice { padding: 12px 13px; color: #795800; background: #ffcb4820; border: 1px solid #eab83438; border-radius: 13px; font-size: 13px; line-height: 1.45; }
.detail-card { display: grid; gap: 15px; }
.detail-description { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; }
.message-list { display: grid; gap: 10px; }
.message { max-width: 88%; padding: 11px 13px; border-radius: 16px 16px 16px 5px; background: var(--card); border: 1px solid var(--line); justify-self: start; }
.message.mine { justify-self: end; border: 0; border-radius: 16px 16px 5px 16px; color: var(--accent-text); background: var(--accent); }
.message.system { justify-self: center; max-width: 100%; padding: 6px 10px; border: 0; color: var(--muted); background: transparent; text-align: center; font-size: 12px; }
.message-author { margin: 0 0 4px; font-size: 10px; font-weight: 700; opacity: .76; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.45; }
.message-time { margin-top: 6px; text-align: right; font-size: 10px; opacity: .67; }
.message-composer { display: grid; gap: 8px; padding-top: 4px; }
.message-compose-row { display: flex; align-items: end; gap: 8px; }
.message-compose-row .text-area { min-height: 45px; max-height: 150px; flex: 1; }
.send-button { width: 48px; height: 47px; flex: 0 0 auto; padding: 0; border-radius: 14px; font-size: 20px; }
.chat-header { display: flex; align-items: center; gap: 10px; }
.avatar { width: 39px; height: 39px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: var(--accent); background: var(--soft); font-weight: 750; }
.chat-header strong { display: block; font-size: 14px; }
.chat-header span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.bottom-nav { position: fixed; z-index: 5; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 680px); display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; gap: 5px; padding: 9px 12px calc(9px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 91%, transparent); border-top: 1px solid var(--line); backdrop-filter: blur(18px); }
.nav-button { min-width: 0; display: grid; justify-items: center; gap: 4px; padding: 5px 2px; color: var(--muted); border: 0; border-radius: 12px; background: transparent; font-size: 10px; }
.nav-button .nav-icon { font-size: 19px; line-height: 1; }
.nav-button.active { color: var(--accent); background: var(--soft); font-weight: 700; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); max-width: calc(100vw - 30px); padding: 12px 15px; border-radius: 14px; color: #fff; background: #1d2735; box-shadow: 0 8px 28px #0003; opacity: 0; pointer-events: none; transition: .22s ease; font-size: 13px; text-align: center; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.confirm-dialog { width: min(calc(100% - 32px), 420px); padding: 0; border: 0; border-radius: 20px; color: var(--text); background: var(--card); box-shadow: 0 22px 70px #0004; }
.confirm-dialog::backdrop { background: #10182588; backdrop-filter: blur(3px); }
.confirm-card { padding: 20px; }
.confirm-card h2 { margin: 0; font-size: 18px; }
.confirm-card p { margin: 9px 0 18px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.confirm-actions { display: flex; gap: 9px; }
.confirm-actions > * { flex: 1; }
.error-box { padding: 14px; border: 1px solid #d6424240; border-radius: 14px; color: var(--danger); background: #d642420d; font-size: 13px; line-height: 1.45; }
.toolbar { display: flex; gap: 8px; align-items: center; }
.toolbar .text-input { min-height: 42px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.privacy-action { width: 100%; margin-top: 10px; color: var(--danger); }
@media (min-width: 560px) { .shell { padding-left: 22px; padding-right: 22px; } .welcome { padding: 24px; } .request-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; } }
