/* MarkOS v1 */
:root { color-scheme: dark light; }

html[data-theme="dark"] {
  --bg: #0b1020;
  --bg-soft: #121831;
  --panel: #161d3a;
  --panel-2: #1c2447;
  --line: #26305c;
  --text: #e6eaf6;
  --text-dim: #97a0c3;
  --accent: #38bdf8;
  --danger: #f87171;
  --ok-bg: #0f2e22;
  --ok-text: #6ee7b7;
  --err-bg: #3a1420;
  --err-text: #fda4af;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
html[data-theme="light"] {
  --bg: #f2f4fb;
  --bg-soft: #e9edf8;
  --panel: #ffffff;
  --panel-2: #f4f6fd;
  --line: #d7ddf0;
  --text: #1c2340;
  --text-dim: #5b6488;
  --accent: #0284c7;
  --danger: #dc2626;
  --ok-bg: #dcfce7;
  --ok-text: #166534;
  --err-bg: #fee2e2;
  --err-text: #991b1b;
  --shadow: 0 8px 24px rgba(28, 35, 64, .10);
}

* { box-sizing: border-box; }
html { overflow-x: hidden; } /* html only; both breaks wheel scrolling */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[hidden] { display: none !important; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.main { min-width: 0; }
.content { padding: 20px 26px 60px; max-width: 1200px; }

/* Rail: the signature element. Each section owns a hue via --sec. */
.rail {
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #38bdf8, #818cf8 55%, #c084fc);
  color: #0b1020; font-weight: 800; font-size: 18px;
}
.brand-name { font-weight: 700; letter-spacing: .04em; font-size: 17px; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rail-foot { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 10px; }
.rail-link {
  --sec: var(--accent);
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  color: var(--text-dim); font-weight: 600;
  border-left: 3px solid transparent;
}
.rail-link:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.rail-link.active {
  color: var(--text);
  background: color-mix(in srgb, var(--sec) 14%, transparent);
  border-left-color: var(--sec);
}
.rail-glyph { color: var(--sec); width: 18px; text-align: center; font-size: 15px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 26px; border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 18px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { color: var(--text-dim); font-weight: 600; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--text); font-size: 16px; cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); text-decoration: none; }
.menu-btn { display: none; }

/* Buttons and forms */
.btn {
  display: inline-block; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: 14px; line-height: 1.55;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #06121f; }
html[data-theme="light"] .btn-primary { color: #ffffff; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 9px; font-size: 13px; border-radius: 7px; line-height: 1.45; }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; }
.inline-form { display: inline; }

label { display: block; font-weight: 600; margin: 12px 0 5px; font-size: 14px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
input[type="text"], input[type="password"], input[type="url"], input[type="date"], select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); font: inherit;
}
textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; align-items: end; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.check-col { padding-bottom: 10px; }
.hint { color: var(--text-dim); font-size: 13px; margin: 6px 0 0; }
.url-row { display: flex; gap: 8px; }
.url-row input { flex: 1; }

/* Cards */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 13px; padding: 16px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 8px; font-size: 15.5px; }
.card h3 a { color: var(--text); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card-link { color: var(--text); }
.card-link:hover { text-decoration: none; color: var(--accent); }
a.card { color: var(--text); display: block; }
a.card:hover { text-decoration: none; border-color: var(--accent); }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.card-sub { color: var(--text-dim); font-size: 13.5px; margin: 6px 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-actions { display: flex; gap: 8px; margin-top: 10px; }
.form-card { max-width: 760px; margin-bottom: 20px; border-top: 3px solid var(--sec, var(--accent)); }
.form-card h2 { margin: 2px 0 4px; font-size: 17px; }

/* Badges */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .01em;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text-dim);
}
.st-inbox    { color: #93c5fd; border-color: #3b5bdb55; }
.st-planning { color: #fbbf24; border-color: #b4530955; }
.st-progress { color: #5eead4; border-color: #0f766e66; }
.st-done     { color: #86efac; border-color: #15803d66; }
.st-archived { color: var(--text-dim); }
html[data-theme="light"] .st-inbox    { color: #1d4ed8; background: #dbeafe; border-color: #bfdbfe; }
html[data-theme="light"] .st-planning { color: #92400e; background: #fef3c7; border-color: #fde68a; }
html[data-theme="light"] .st-progress { color: #0f766e; background: #ccfbf1; border-color: #99f6e4; }
html[data-theme="light"] .st-done     { color: #166534; background: #dcfce7; border-color: #bbf7d0; }
.pr-high { color: #fca5a5; border-color: #b91c1c66; }
.pr-med  { color: #fdba74; border-color: #c2410c55; }
.pr-low  { color: #a5b4fc; border-color: #4338ca55; }
html[data-theme="light"] .pr-high { color: #b91c1c; background: #fee2e2; border-color: #fecaca; }
html[data-theme="light"] .pr-med  { color: #c2410c; background: #ffedd5; border-color: #fed7aa; }
html[data-theme="light"] .pr-low  { color: #4338ca; background: #e0e7ff; border-color: #c7d2fe; }
.badge-pin  { color: #fbbf24; border-color: #b4530966; }
.badge-proj { --sec: #818cf8; color: var(--sec); border-color: color-mix(in srgb, var(--sec) 40%, transparent); }
.badge-kind { --sec: #fb7185; color: var(--sec); border-color: color-mix(in srgb, var(--sec) 40%, transparent); }
a.badge-proj:hover { text-decoration: none; background: color-mix(in srgb, var(--sec) 14%, transparent); }

/* Progress */
.progress-row { display: flex; align-items: center; gap: 10px; }
.progress-row.big { margin: 6px 0 22px; max-width: 560px; }
.progress {
  --bar: var(--accent);
  flex: 1; height: 9px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  overflow: hidden;
}
.progress-fill { display: block; height: 100%; background: var(--bar); border-radius: 999px; transition: width .25s ease; }
.progress-num { font-size: 12.5px; font-weight: 700; color: var(--text-dim); min-width: 34px; text-align: right; }
.progress-caption { color: var(--text-dim); font-size: 13px; white-space: nowrap; }

/* Section heads, toolbars, tabs */
.sec-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 26px 0 12px; padding-left: 10px;
  border-left: 4px solid var(--sec, var(--accent));
}
.sec-head h2 { margin: 0; font-size: 16.5px; }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  padding: 6px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  color: var(--text-dim); border: 1px solid transparent;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active {
  color: var(--text);
  background: color-mix(in srgb, var(--sec, var(--accent)) 15%, transparent);
  border-color: color-mix(in srgb, var(--sec, var(--accent)) 45%, transparent);
}

/* Dashboard */
.dash-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.dash-greet { font-size: 20px; font-weight: 700; margin: 0; }
.dash-sub { color: var(--text-dim); margin: 2px 0 0; }
.customize { position: relative; }
.customize summary { list-style: none; }
.customize summary::-webkit-details-marker { display: none; }
.customize-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; min-width: 230px; box-shadow: var(--shadow);
}
.customize-panel .check { margin: 8px 0; }
.customize-panel .btn { margin-top: 8px; }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 6px; }
.qa {
  --sec: var(--accent);
  padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 14px;
  color: var(--sec);
  background: color-mix(in srgb, var(--sec) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--sec) 40%, transparent);
}
.qa:hover { text-decoration: none; background: color-mix(in srgb, var(--sec) 22%, transparent); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 16px; }
.stat-card {
  --sec: var(--accent);
  display: flex; flex-direction: column; gap: 2px;
  background: var(--panel); border: 1px solid var(--line);
  border-top: 3px solid var(--sec);
  border-radius: 12px; padding: 14px 16px; color: var(--text);
}
.stat-card:hover { text-decoration: none; border-color: var(--sec); }
.stat-num { font-size: 26px; font-weight: 800; color: var(--sec); line-height: 1.1; }
.stat-label { color: var(--text-dim); font-weight: 600; font-size: 13.5px; }

/* Tasks */
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 11px; padding: 10px 14px;
}
.task-row.done .task-title { text-decoration: line-through; color: var(--text-dim); }
.task-check { width: 18px; height: 18px; accent-color: #2dd4bf; cursor: pointer; flex-shrink: 0; }
.task-title { flex: 1; min-width: 0; font-weight: 600; }
.task-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.meta-date { color: var(--text-dim); font-size: 12.5px; white-space: nowrap; }
.quick-add { display: flex; gap: 8px; margin-bottom: 14px; max-width: 640px; }
.quick-add input { flex: 1; }

/* Detail pages */
.detail-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding-left: 10px; border-left: 4px solid var(--sec, var(--accent)); margin-bottom: 12px; }
.detail-desc { color: var(--text-dim); margin: 8px 0 0; max-width: 70ch; }
.detail-actions { display: flex; gap: 8px; align-items: flex-start; }

/* Lists and tables */
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.recent-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 14px;
}
.recent-list a { color: var(--text); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table th { color: var(--text-dim); font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; }
.data-table tr:last-child td { border-bottom: 0; }
.inline-details { display: inline-block; }
.inline-details summary { list-style: none; display: inline-block; }
.inline-details summary::-webkit-details-marker { display: none; }
.mini-form { display: flex; gap: 6px; margin-top: 6px; }
.mini-form input { width: 220px; }
.pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.pager-info { color: var(--text-dim); font-size: 13.5px; }

/* Flash, empty */
.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-weight: 600; }
.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-err { background: var(--err-bg); color: var(--err-text); }
.empty { color: var(--text-dim); background: var(--panel); border: 1px dashed var(--line); border-radius: 12px; padding: 18px; }

/* Auth */
.auth-body { display: grid; place-items: center; min-height: 100vh; background: var(--bg); padding: 20px; }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 26px 26px 30px; box-shadow: var(--shadow);
}
.auth-brand { justify-content: center; margin-bottom: 8px; }
.auth-tag { color: var(--text-dim); text-align: center; font-size: 13.5px; margin: 0 0 14px; }
.auth-card .btn-block { margin-top: 18px; }
.auth-card .check { margin-top: 12px; }

/* Mobile */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .rail.open { transform: translateX(0); }
  .menu-btn { display: inline-grid; }
  .content { padding: 16px 14px 60px; }
  .topbar { padding: 10px 14px; }
  .who { display: none; }
  .task-row { flex-wrap: wrap; }
  .task-meta { width: 100%; justify-content: flex-start; }
  .mini-form input { width: 100%; }
  .mini-form { flex-wrap: wrap; }
}

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

/* Phase 2: calendar */
.cal-nav { display: flex; align-items: center; gap: 12px; }
.cal-title { margin: 0; font-size: 17px; min-width: 150px; text-align: center; }
.cal-legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 0 0 12px; color: var(--text-dim); font-size: 13px; }
.cal-key { display: inline-flex; align-items: center; gap: 6px; }
.cal-dot { --sec: var(--accent); width: 10px; height: 10px; border-radius: 3px; background: var(--sec); display: inline-block; }
.cal-dot-open { background: transparent; border: 2px solid var(--sec); }
.cal-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); }
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 640px; }
.cal th { padding: 10px 8px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); border-bottom: 1px solid var(--line); text-align: left; }
.cal td { vertical-align: top; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 6px; height: 96px; }
.cal td:last-child { border-right: 0; }
.cal tr:last-child td { border-bottom: 0; }
.cal-empty { background: var(--bg-soft); }
.cal-num { display: inline-block; font-weight: 700; font-size: 13px; color: var(--text-dim); margin-bottom: 4px; padding: 1px 6px; border-radius: 7px; }
.cal-today { background: color-mix(in srgb, #4ade80 8%, transparent); }
.cal-today .cal-num { background: #4ade80; color: #06121f; }
.cal-chip {
  --sec: var(--accent);
  display: block; margin: 2px 0; padding: 2px 7px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: var(--text);
  background: color-mix(in srgb, var(--sec) 16%, transparent);
  border-left: 3px solid var(--sec);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-chip:hover { text-decoration: none; background: color-mix(in srgb, var(--sec) 28%, transparent); }
.chip-task { --sec: #2dd4bf; }
.chip-proj { --sec: #818cf8; }
.chip-start { border-left-style: dashed; background: transparent; border: 1px dashed var(--sec); border-left-width: 3px; }
.chip-done { opacity: .55; text-decoration: line-through; }
.cal-more { display: block; font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.agenda-done { opacity: .6; }
.agenda-done, .agenda-done:hover { text-decoration: line-through; }

/* Phase 2: templates */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tpl-picker {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 4px solid var(--sec, var(--accent));
  border-radius: 11px; padding: 10px 14px; margin-bottom: 14px; max-width: 760px;
}
.tpl-picker label { margin: 0; white-space: nowrap; }
.tpl-picker select { width: auto; min-width: 200px; flex: 1; }

@media (max-width: 860px) {
  .cal td { height: 72px; }
  .cal-title { min-width: 0; }
}

/* Phase 3: areas, tags, chips, filters, version */
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.chip {
  --sec: var(--accent);
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  color: var(--sec);
  background: color-mix(in srgb, var(--sec) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--sec) 38%, transparent);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
}
.area-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check {
  --sec: var(--accent);
  padding: 5px 11px; border-radius: 999px; font-size: 13.5px;
  background: color-mix(in srgb, var(--sec) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--sec) 35%, transparent);
  cursor: pointer;
}
.chip-check:has(input:checked) {
  background: color-mix(in srgb, var(--sec) 24%, transparent);
  border-color: var(--sec);
}
.chip-check input { accent-color: var(--sec); }
.org-filter {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 14px;
}
.org-filter select { width: auto; min-width: 150px; }
.area-card { border-top: 3px solid var(--sec, var(--accent)); }
.tag-manage { display: flex; flex-direction: column; gap: 8px; max-width: 640px; }
.tag-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 11px; padding: 8px 12px;
}
.tag-row input[type="text"] { flex: 1; }
.tag-row input[type="color"] { width: 36px; height: 32px; padding: 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); flex-shrink: 0; }
input[type="color"] { cursor: pointer; }
.rail-version { display: block; color: var(--text-dim); font-size: 11.5px; padding: 8px 10px 0; letter-spacing: .03em; }
.list-toolbar .hint { margin: 0; max-width: 60ch; }

@media (max-width: 860px) {
  .tag-row { flex-wrap: wrap; }
}

/* Phase 4: attachments and dashboard banner */
.att-section { margin-top: 4px; }
.att-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.att-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 11px; padding: 8px 12px;
}
.att-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.att-name { flex: 1; min-width: 0; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-upload { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; max-width: 760px; }
.att-upload input[type="file"] { flex: 1; min-width: 220px; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
.att-upload .hint { flex-basis: 100%; }
.dash-banner { margin: 0 0 16px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.dash-banner img { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.customize-divider { border-top: 1px solid var(--line); margin: 12px 0; }
.customize-panel { max-width: 300px; }
.banner-form label { margin-top: 0; }
.banner-form input[type="file"] { width: 100%; margin-bottom: 8px; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }

@media (max-width: 860px) {
  .att-row { flex-wrap: wrap; }
}
