:root {
  --ink: #1f1b3a; --muted: #6b6790; --bg: #f4f2fb; --card: #fff; --line: #e6e2f5;
  --violet: #5b4bff; --green: #18a35f; --red: #d9363e; --yellow: #f5a700;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink);
  background: var(--bg); font-size: 16px; -webkit-text-size-adjust: 100%;
  padding: 0 0 calc(24px + env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }
h1 { font-size: 26px; margin: 0 0 6px; }
h2 { font-size: 21px; margin: 18px 0 12px; }
h3 { font-size: 17px; margin: 18px 0 10px; }
p { margin: 0 0 10px; }
.screen { max-width: 720px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.error { color: var(--red); font-weight: 600; min-height: 20px; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; }

.panel { background: var(--card); border-radius: 18px; padding: 18px; box-shadow: 0 4px 16px rgba(40, 30, 110, .08); margin: 0 0 12px; }
.narrow { max-width: 420px; margin: 48px auto 0; display: flex; flex-direction: column; gap: 6px; }
#login, #change { padding: 0 16px; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 15px; margin-bottom: 12px; }
label.check { flex-direction: row; align-items: center; gap: 10px; min-height: 48px; }
input, select, textarea {
  font: inherit; font-size: 17px; font-weight: 400; color: var(--ink); background: #fff;
  border: 2px solid var(--line); border-radius: 12px; padding: 0 12px; min-height: 48px; width: 100%;
}
textarea { padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); }
input[type="checkbox"] { width: 26px; height: 26px; min-height: 0; accent-color: var(--violet); }

.btn {
  font: inherit; font-weight: 700; font-size: 16px; min-height: 48px; padding: 0 18px; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--violet); border-color: var(--violet); color: #fff; }
.btn.ok { background: var(--green); border-color: var(--green); color: #fff; flex: 1; }
.btn.no { background: #fff; border-color: var(--red); color: var(--red); min-width: 56px; }
.btn.ghost { background: rgba(255, 255, 255, .14); border-color: transparent; color: #fff; }
.small-btn { min-height: 44px; font-size: 15px; padding: 0 12px; }
.small-link { color: var(--muted); text-align: center; padding: 14px; }

.bar {
  position: sticky; top: 0; z-index: 5; background: var(--ink); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.sum-main { font-size: 18px; font-weight: 800; }
.sum-sub { font-size: 13px; opacity: .8; margin-top: 2px; }
.tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: calc(66px + env(safe-area-inset-top)); z-index: 4; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  font: inherit; font-weight: 700; font-size: 15px; min-height: 44px; padding: 0 14px; border-radius: 22px;
  border: 0; background: var(--bg); color: var(--ink); white-space: nowrap; cursor: pointer; position: relative;
}
.tabs button.active { background: var(--violet); color: #fff; }
.badge { display: inline-block; margin-left: 6px; min-width: 22px; padding: 1px 6px; border-radius: 11px; background: var(--red); color: #fff; font-size: 13px; }
main { padding: 0 16px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--card); border-radius: 16px; padding: 14px; box-shadow: 0 2px 10px rgba(40, 30, 110, .06);
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: start;
}
.item.off { opacity: .55; }
.item-title { font-weight: 700; font-size: 17px; }
.item-stars { font-weight: 800; font-size: 18px; color: var(--yellow); white-space: nowrap; }
.item-stars.minus { color: var(--red); }
.item-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.item-actions .small-btn { flex: 1; }
.reject-note { grid-column: 1 / -1; }

.grid2, .grid3 { display: grid; gap: 0 12px; }
.grid2 { grid-template-columns: 1fr 1fr; }
.grid3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 420px) { .grid3 { grid-template-columns: 1fr 1fr; } .grid3 label:first-child { grid-column: 1 / -1; } }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.row-gap { display: flex; gap: 10px; }

.settings { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.settings th { text-align: left; font-weight: 600; font-size: 15px; padding: 10px 10px 10px 0; vertical-align: middle; }
.settings th code { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.settings td { width: 42%; padding: 6px 0; }
.settings tr + tr { border-top: 1px solid var(--line); }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 480px; z-index: 20; background: var(--ink); color: #fff; padding: 14px 16px; border-radius: 14px; font-weight: 700; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.toast-error { background: var(--red); }
#task-form { scroll-margin-top: calc(140px + env(safe-area-inset-top)); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.btn.danger { border-color: var(--red); color: var(--red); white-space: normal; text-align: center; padding: 8px 14px; }
.event { background: var(--card); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; border-left: 5px solid var(--line); }
.event .muted { grid-column: 1 / -1; }
.ev-label { font-weight: 700; }
.ev-success { border-left-color: var(--green); }
.ev-fail { border-left-color: var(--yellow); }
.ev-locked, .ev-rate_limited { border-left-color: var(--red); }
.ev-logout_all { border-left-color: var(--violet); }
.item.lock-on { border-left: 5px solid var(--red); }
.ev-hard_locked { border-left-color: var(--red); }
.ev-unlock { border-left-color: var(--green); }
