:root {
  color-scheme: light;
  --bg: #F2F3F5;
  --surface: #FFFFFF;
  --ink: #1B1F27;
  --muted: #6B7280;
  --line: #E3E5E9;
  --accent: #2F5FE8;
  --accent-ink: #FFFFFF;
  --danger: #D64545;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(20, 24, 33, .08);
  --hover: rgba(27, 31, 39, .06);
  --accent-soft: rgba(47, 95, 232, .1);
  --danger-soft: rgba(214, 69, 69, .09);
  --unread-bg: #F5F8FF;
  --warn-ink: #9A6700;
  --warn-bg: #FFF3D6;
  --overlay: rgba(20, 24, 33, .45);
  --toast-bg: #1B1F27;
  --toast-ink: #FFFFFF;
  --pop-shadow: 0 8px 24px rgba(20, 24, 33, .14);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15181E;
  --surface: #1E232B;
  --ink: #E7E9EE;
  --muted: #99A1AD;
  --line: #2D333E;
  --accent: #6B8DF2;
  --accent-ink: #10131A;
  --danger: #E06C6C;
  --shadow: 0 1px 3px rgba(0, 0, 0, .35);
  --hover: rgba(231, 233, 238, .07);
  --accent-soft: rgba(107, 141, 242, .16);
  --danger-soft: rgba(224, 108, 108, .14);
  --unread-bg: #1E2634;
  --warn-ink: #F0C24B;
  --warn-bg: #3A3115;
  --overlay: rgba(0, 0, 0, .6);
  --toast-bg: #E7E9EE;
  --toast-ink: #15181E;
  --pop-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* модалки/панели: перебиваем display у классов */
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button { font: inherit; cursor: pointer; }
input, textarea, select {
  font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 9px; background: var(--surface); width: 100%;
}
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

/* ---------- вход ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 15% 10%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 500px at 90% 90%, var(--danger-soft), transparent 55%),
    var(--bg);
}
.login-card {
  width: 340px; background: var(--surface); border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.login-mark { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.login-sub { margin: -10px 0 4px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.login-hint { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.form-error { margin: 0; color: var(--danger); font-size: 13px; }

/* ---------- кнопки ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 6px; padding: 8px 14px; color: var(--ink);
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-danger { background: none; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: var(--surface); }
.btn-small { padding: 5px 10px; font-size: 13px; }
.linkbtn { border: 0; background: none; color: var(--accent); padding: 0; font-size: 12px; }
.linkbtn:hover { text-decoration: underline; }
.iconbtn {
  border: 0; background: none; color: var(--ink);
  padding: 6px 8px; border-radius: 6px; position: relative; display: inline-flex; align-items: center; gap: 6px;
}
.iconbtn:hover { background: var(--hover); }

/* ---------- каркас ---------- */
.topbar {
  height: 50px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 6px; padding: 0 14px; position: relative;
}
.topbar-brand { font-weight: 800; letter-spacing: -.3px; font-size: 17px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.brand-glyph {
  width: 20px; height: 20px; border-radius: 5px; background: var(--accent); position: relative; flex: none;
}
.brand-glyph::before {
  content: ""; position: absolute; inset: 4px;
  background:
    linear-gradient(var(--accent-ink), var(--accent-ink)) left   top / 3px 55% no-repeat,
    linear-gradient(var(--accent-ink), var(--accent-ink)) center top / 3px 90% no-repeat,
    linear-gradient(var(--accent-ink), var(--accent-ink)) right  top / 3px 40% no-repeat;
  border-radius: 1px;
}
.topbar-spacer { flex: 1; }
.user-name { font-weight: 600; }
.badge {
  position: absolute; top: 1px; right: 1px; min-width: 15px; height: 15px;
  background: var(--danger); color: #fff; border-radius: 8px;
  font-size: 10px; line-height: 15px; text-align: center; padding: 0 3px; font-weight: 700;
}
.drop {
  position: absolute; top: 46px; right: 12px; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--pop-shadow); min-width: 190px; overflow: hidden;
}
.drop-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 14px; }
.drop-item:hover { background: var(--hover); }
.drop-notif { width: 340px; max-height: 420px; overflow-y: auto; }
.drop-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13px; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.notif-item:hover { background: var(--hover); }
.notif-item.unread { border-left: 3px solid var(--accent); background: var(--unread-bg); }
.notif-title { font-weight: 600; font-size: 13px; }
.notif-body, .notif-time { font-size: 12px; color: var(--muted); }
.notif-empty { padding: 18px 14px; color: var(--muted); font-size: 13px; }

.layout { display: flex; height: calc(100vh - 50px); }
.sidebar {
  width: 220px; flex: none; background: var(--surface); border-right: 1px solid var(--line);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto;
}
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); padding: 0 6px; }
.board-link {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: none; padding: 8px 6px; border-radius: 6px; text-align: left;
}
.board-link:hover { background: var(--hover); }
.board-link.active { background: var(--accent-soft); font-weight: 600; }
.board-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.side-newboard { display: flex; gap: 6px; margin-top: auto; }

.main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

/* ---------- домашняя ---------- */
.home { padding: 34px; overflow-y: auto; flex: 1; background: var(--user-bg, transparent); }
.home h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.4px; }
.home-sub { color: var(--muted); margin: 0 0 22px; }
.home-grid { display: flex; flex-wrap: wrap; gap: 14px; }
.home-tile {
  width: 210px; height: 96px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; text-align: left; box-shadow: var(--shadow);
  border-top: 3px solid var(--accent); font-weight: 700; font-size: 15px;
}
.home-tile:hover { transform: translateY(-1px); }

/* ---------- доска ---------- */
.board-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px 10px;
  border-bottom: 3px solid var(--accent);
  background: var(--surface);
}
.board-title { font-size: 18px; font-weight: 800; letter-spacing: -.3px; border: 0; background: none; padding: 2px 4px; width: auto; max-width: 40vw; }
.board-members { display: flex; align-items: center; gap: 4px; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: var(--surface);
  font-size: 11px; font-weight: 700; display: grid; place-items: center; text-transform: uppercase;
}
.board-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.board-scroll {
  flex: 1; overflow-x: auto; overflow-y: hidden; padding: 16px 18px;
  background: var(--user-bg, transparent);
}
.columns { display: flex; gap: 14px; height: 100%; align-items: flex-start; }
.column {
  width: 272px; flex: none; max-height: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.col-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; }
.col-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
  border: 0; background: none; padding: 2px 0; color: var(--ink); flex: 1; min-width: 0;
}
.col-count {
  font-size: 11px; font-weight: 700; color: var(--muted);
  background: var(--bg); border-radius: 10px; padding: 1px 7px;
}
.col-del { border: 0; background: none; color: var(--muted); padding: 2px 4px; border-radius: 4px; }
.col-del:hover { color: var(--danger); background: var(--danger-soft); }
.col-cards { padding: 6px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 30px; }
.col-add { padding: 8px; }
.col-add input { font-size: 13px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 10px; cursor: pointer; box-shadow: var(--shadow);
}
.card { transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.card:hover { border-color: var(--muted); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,.10); }
.card.dragging { opacity: .55; transform: rotate(2deg); }
.card-title { font-weight: 600; font-size: 13.5px; word-break: break-word; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  font-size: 11px; color: var(--muted); background: var(--bg);
  border-radius: 4px; padding: 1px 6px; display: inline-flex; align-items: center; gap: 3px;
}
.chip.due-soon { color: var(--warn-ink); background: var(--warn-bg); }
.chip.due-over { color: var(--surface); background: var(--danger); }
.chip.assignee { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.add-column { width: 272px; flex: none; }
.add-column input { background: var(--surface); opacity: .85; }

.drop-hint { border: 2px dashed var(--accent); border-radius: 6px; height: 42px; background: var(--accent-soft); }

/* ---------- модалка ---------- */
.modal-back {
  position: fixed; inset: 0; background: var(--overlay); z-index: 50;
  display: grid; place-items: start center; padding: 6vh 16px; overflow-y: auto;
}
.modal {
  width: 760px; max-width: 100%; background: var(--bg); border-radius: 10px;
  box-shadow: var(--pop-shadow); padding: 18px 20px 22px;
}
.modal-top { display: flex; gap: 10px; align-items: center; }
.cm-title { font-size: 17px; font-weight: 700; background: none; border-color: transparent; }
.cm-title:hover { border-color: var(--line); }
.modal-grid { display: grid; grid-template-columns: 1fr 210px; gap: 22px; margin-top: 12px; }
.modal-aside { display: flex; flex-direction: column; gap: 8px; }
.aside-gap { flex: 1; min-height: 18px; }
.cm-section { margin-bottom: 20px; }
.cm-label { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 700; margin-bottom: 7px; }
.cm-progress { text-transform: none; letter-spacing: 0; }
.inline-form { display: flex; gap: 6px; margin-top: 8px; }
.check-item { display: flex; align-items: center; gap: 8px; padding: 4px 2px; }
.check-item input[type=checkbox] { width: auto; }
.check-item.done .check-text { text-decoration: line-through; color: var(--muted); }
.check-text { flex: 1; }
.x-del { border: 0; background: none; color: var(--muted); border-radius: 4px; }
.x-del:hover { color: var(--danger); }
.attach-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px; }
.attach-row a { color: var(--accent); text-decoration: none; flex: 1; word-break: break-all; }
.attach-row a:hover { text-decoration: underline; }
.attach-size { color: var(--muted); font-size: 12px; }
.file-btn { display: inline-block; margin-top: 8px; }
.comment { padding: 8px 0; border-bottom: 1px solid var(--line); }
.comment-head { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.comment-head b { color: var(--ink); }
.comment-body { white-space: pre-wrap; word-break: break-word; }

/* ---------- админка ---------- */
.admin { padding: 30px 34px; overflow-y: auto; }
.admin h1 { margin: 0 0 18px; font-size: 22px; letter-spacing: -.4px; }
.admin table { border-collapse: collapse; width: 100%; max-width: 860px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.admin th, .admin td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.admin th { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); background: var(--bg); }
.admin .muted { color: var(--muted); }
.admin-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 20px; max-width: 860px; }
.admin-form input { width: 180px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.tag.off { background: var(--danger-soft); color: var(--danger); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--toast-bg); color: var(--toast-ink); padding: 10px 18px; border-radius: 8px;
  font-size: 13px; z-index: 90; box-shadow: 0 8px 22px rgba(0,0,0,.3);
}

.members-panel { position: absolute; top: 46px; right: 18px; z-index: 30; width: 280px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--pop-shadow); padding: 12px; }
.member-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.member-row .role { color: var(--muted); font-size: 11px; margin-left: auto; }


@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- оформление: выбор фона ---------- */
.bg-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.bg-swatch {
  height: 44px; border-radius: 8px; border: 2px solid var(--line); cursor: pointer; padding: 0;
  background: var(--bg);
}
.bg-swatch:hover { border-color: var(--muted); }
.bg-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* ---------- новое: таймер, "+", настройки ---------- */
.cm-addbtn {
  border: 1px dashed var(--line); background: none; color: var(--muted);
  border-radius: 6px; padding: 7px 14px; opacity: .65;
}
.cm-addbtn:hover { opacity: 1; color: var(--accent); border-color: var(--accent); }
.cm-add-menu { position: absolute; margin-top: 4px; right: auto; top: auto; }
.timer-row { display: flex; align-items: center; gap: 12px; }
.timer-display { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.timer-display.running { color: var(--accent); }
.chip.timer-on { color: var(--accent-ink); background: var(--accent); font-weight: 700; }
.modal-narrow { width: 520px; }
.cm-title-static { font-size: 17px; font-weight: 700; flex: 1; }
.scale-row { display: flex; align-items: center; gap: 10px; }
.scale-value { font-weight: 800; min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.hint code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.bg-swatch { background-size: cover; background-position: center; }

/* ---------- мобильная вёрстка ---------- */
@media (max-width: 760px) {
  .sidebar { display: none; }
  input, textarea, select { font-size: 16px; } /* iOS: не зумить при фокусе */
  .topbar { padding: 0 10px; }
  .layout { height: calc(100dvh - 50px); }
  .home { padding: 18px; }
  .home-tile { width: calc(50% - 7px); min-width: 140px; }
  .board-head { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .board-title { max-width: 100%; font-size: 16px; }
  .board-tools { margin-left: 0; width: 100%; justify-content: flex-start; }
  .board-scroll { padding: 12px 10px; scroll-snap-type: x proximity; }
  .columns { gap: 10px; }
  .column, .add-column { width: 86vw; scroll-snap-align: center; }
  .modal-back { padding: 0; }
  .modal { width: 100%; min-height: 100dvh; border-radius: 0; padding: 14px 14px 28px; }
  .modal-grid { grid-template-columns: 1fr; gap: 14px; }
  .modal-narrow { width: 100%; }
  .drop-notif { width: calc(100vw - 20px); right: 10px; }
  .members-panel { right: 10px; width: calc(100vw - 20px); max-width: 320px; }
  .btn, .iconbtn { min-height: 38px; }
}
