/* Calmero styles. Colors are tokens; light and dark themes redefine them. */

:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --top: #ffffff;
  --rail: #f1f2f5;
  --side: #f7f8fa;
  --elev: #ffffff;
  --border: #e3e5e9;
  --border-strong: #cfd3da;
  --text: #1e1f21;
  --muted: #6d6e73;
  --faint: #a7a9af;
  --hover: #f0f2f5;
  --active: #e4e9f5;
  --accent: #4573d2;
  --accent-hover: #3a63b8;
  --accent-text: #ffffff;
  --danger: #c8333a;
  --green: #2e9e64;
  --overdue: #c8333a;
  --shadow: 0 8px 28px rgba(20, 23, 31, .14), 0 1px 3px rgba(20, 23, 31, .08);
  --dotgrid: #dfe2e7;

  --red-bg: #fde2e1; --red-fg: #a1262b;
  --orange-bg: #fde7d4; --orange-fg: #9a4a0c;
  --yellow-bg: #fbf0c3; --yellow-fg: #735700;
  --green-bg: #dcf3e3; --green-fg: #1d6b3a;
  --teal-bg: #d6f1ef; --teal-fg: #0f6660;
  --blue-bg: #dde7fb; --blue-fg: #2a4fa8;
  --purple-bg: #ece2fb; --purple-fg: #5f35a4;
  --pink-bg: #fbe0ef; --pink-fg: #9b2465;
  --gray-bg: #eceef1; --gray-fg: #4b4f56;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1e1f21;
  --bg-soft: #26272a;
  --top: #2a2b2e;
  --rail: #232427;
  --side: #26272a;
  --elev: #2d2e31;
  --border: #393a3e;
  --border-strong: #4a4c51;
  --text: #f0f0f1;
  --muted: #a3a4a8;
  --faint: #6d6f74;
  --hover: #2f3034;
  --active: #33405e;
  --accent: #5a86e6;
  --accent-hover: #6d95ec;
  --accent-text: #ffffff;
  --danger: #ff6b70;
  --green: #3fb87a;
  --overdue: #ff7b7f;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4);
  --dotgrid: #34363a;

  --red-bg: #5a2326; --red-fg: #ffb4b0;
  --orange-bg: #5a3618; --orange-fg: #ffc79a;
  --yellow-bg: #4f4313; --yellow-fg: #f5dc7a;
  --green-bg: #1e4a2e; --green-fg: #9fe0b4;
  --teal-bg: #164745; --teal-fg: #94e0d9;
  --blue-bg: #233a6b; --blue-fg: #b3c9ff;
  --purple-bg: #3d2a63; --purple-fg: #d3bcff;
  --pink-bg: #5a2443; --pink-fg: #ffb3d9;
  --gray-bg: #3a3c40; --gray-fg: #d0d2d6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
#app { height: 100%; display: flex; flex-direction: column; }
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2 { margin: 0; }
.ic { display: inline-flex; flex: none; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.boot { margin: auto; padding: 40px 16px; color: var(--muted); text-align: center; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
  cursor: pointer; white-space: nowrap; font-weight: 500;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--red-bg); }
.btn.wide { width: 100%; justify-content: center; height: 38px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none;
  border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.faint { color: var(--faint); }
.split { display: inline-flex; }
.split .btn:first-child { border-radius: 6px 0 0 6px; }
.split .split-arrow { border-radius: 0 6px 6px 0; padding: 0 6px; border-left: 1px solid rgba(255, 255, 255, .35); }

/* ---------- Top bar ---------- */
.topbar {
  height: 50px; flex: none; display: flex; align-items: center; gap: 8px;
  padding: 0 12px; background: var(--top); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; text-decoration: none; letter-spacing: -.01em; }
.logo { color: var(--accent); display: inline-flex; }
.theme-toggle { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--hover); border: 1px solid var(--border); }
.tt-btn { width: 32px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.tt-btn.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }

/* ---------- Shell ---------- */
.shell { flex: 1; display: flex; min-height: 0; position: relative; overflow: hidden; }
.rail {
  width: 72px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 0; background: var(--rail); border-right: 1px solid var(--border);
}
.rail-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px; width: 62px; padding: 8px 0;
  border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500;
}
.rail-item:hover { background: var(--hover); color: var(--text); }
.rail-item.active { background: var(--active); color: var(--text); }
.panel {
  width: 236px; flex: none; display: flex; flex-direction: column; gap: 2px;
  padding: 14px 10px; background: var(--side); border-right: 1px solid var(--border);
  transition: margin-left .18s ease; overflow-y: auto;
}
body.panel-collapsed .panel { margin-left: -236px; }
.panel-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 0 10px 8px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: 6px;
  color: var(--text); text-decoration: none; border: 0; background: none; cursor: pointer; text-align: left;
}
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--active); font-weight: 600; }
.nav-item .ic { color: var(--muted); }
.panel-foot { display: flex; gap: 8px; align-items: flex-start; padding: 10px; border-top: 1px solid var(--border); }
.panel-foot:has(.account) { flex-direction: column; align-items: stretch; padding: 10px 0 0; gap: 2px; }
.account { font-size: 12px; color: var(--muted); padding: 0 10px 4px; }
.scrim { display: none; }
.main { flex: 1; min-width: 0; overflow: auto; background: var(--bg); }
.main.board-mode { overflow: hidden; display: flex; flex-direction: column; }

@media (max-width: 760px) {
  .rail { width: 60px; }
  .rail-item { width: 52px; font-size: 10px; }
  .panel {
    position: absolute; left: 60px; top: 0; bottom: 0; z-index: 30; margin-left: 0 !important;
    transform: translateX(calc(-100% - 60px)); transition: transform .18s ease; box-shadow: var(--shadow);
  }
  body.panel-open .panel { transform: none; }
  body.panel-open .scrim { display: block; position: absolute; inset: 0; z-index: 20; background: rgba(0, 0, 0, .3); }
  .hide-sm { display: none; }
}

/* ---------- Pages ---------- */
.page { padding: 22px 28px 64px; max-width: 1400px; }
@media (max-width: 760px) { .page { padding: 16px 16px 48px; } }
.capture { background: var(--bg); padding-bottom: 6px; }
.page-head { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.page-head h1 { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 600; letter-spacing: -.01em; min-width: 0; }
.title-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--active); color: var(--accent); flex: none; }
.title-dot { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 14px 0 18px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 13px; margin-bottom: 10px; }
.back-link:hover { color: var(--text); }
.intro { margin: 6px 0 18px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: 10px; }

/* ---------- Sections and rows ---------- */
.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: center; gap: 4px; padding: 4px 0 8px; }
.section-name { font-size: 16px; font-weight: 600; padding: 0 4px; }
.caret .ic { transition: transform .15s; }
.caret.collapsed .ic { transform: rotate(-90deg); }
.count { color: var(--muted); font-size: 12px; min-width: 14px; }
.table { overflow-x: auto; }
.row { display: grid; min-width: min-content; border-bottom: 1px solid var(--border); }
.col-head { border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.col-head .cell { min-height: 34px; }
.cell { display: flex; align-items: center; min-height: 40px; padding: 0 8px; border-right: 1px solid var(--border); min-width: 0; position: relative; }
.cell:last-child { border-right: 0; }
.col-btn { border: 0; border-right: 1px solid var(--border); background: none; color: var(--muted); cursor: pointer; gap: 4px; font-size: 12px; text-align: left; justify-content: space-between; }
.col-btn:hover { background: var(--hover); color: var(--text); }
.add-col { border: 0; background: none; color: var(--muted); cursor: pointer; justify-content: center; }
.add-col:hover { background: var(--hover); color: var(--text); }
.row.task:hover { background: var(--hover); }
.name-cell { gap: 8px; }
.check {
  width: 18px; height: 18px; flex: none; padding: 0; border-radius: 50%;
  border: 1.5px solid var(--faint); background: none; color: transparent; cursor: pointer; display: grid; place-items: center;
}
.check:hover { color: var(--green); border-color: var(--green); }
.check.on { background: var(--green); border-color: var(--green); color: #fff; }
.task-name { padding: 2px 4px; border-radius: 4px; outline: none; min-width: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text; }
.task-name:focus { box-shadow: 0 0 0 1px var(--accent); background: var(--bg); text-overflow: clip; }
.suffix { color: var(--muted); white-space: nowrap; flex: none; }
.recur { color: var(--muted); display: inline-flex; }
.done .task-name, .done .suffix { text-decoration: line-through; color: var(--muted); }
.row-open { margin-left: auto; width: 26px; height: 26px; opacity: 0; }
.row:hover .row-open, .row-open:focus-visible { opacity: 1; }
@media (hover: none) { .row-open { opacity: 1; } }
.add-task-row {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px;
  border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--muted); cursor: pointer; text-align: left;
}
.add-task-row:hover { background: var(--hover); color: var(--text); }

/* cells */
.cell-btn {
  display: flex; align-items: center; width: 100%; min-height: 32px; padding: 0 2px;
  border: 0; background: none; color: inherit; cursor: pointer; text-align: left; min-width: 0;
}
.cell-btn.overdue { color: var(--overdue); }
.cell-input { width: 100%; min-width: 0; height: 30px; padding: 0 6px; border: 0; border-radius: 4px; background: none; color: inherit; font: inherit; }
.cell-input:focus { outline: none; box-shadow: 0 0 0 1px var(--accent); background: var(--bg); }
.placeholder { color: var(--faint); opacity: 0; }
.row:hover .placeholder, .cell-btn:focus-visible .placeholder { opacity: 1; }
.date-cell { display: flex; align-items: center; width: 100%; position: relative; }
.date-hidden { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.clear-btn { border: 0; background: none; color: var(--faint); cursor: pointer; padding: 2px; border-radius: 4px; display: none; }
.row:hover .clear-btn { display: inline-flex; }
.clear-btn:hover { color: var(--text); background: var(--border); }

.chip { display: inline-block; max-width: 100%; padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-red { background: var(--red-bg); color: var(--red-fg); }
.c-orange { background: var(--orange-bg); color: var(--orange-fg); }
.c-yellow { background: var(--yellow-bg); color: var(--yellow-fg); }
.c-green { background: var(--green-bg); color: var(--green-fg); }
.c-teal { background: var(--teal-bg); color: var(--teal-fg); }
.c-blue { background: var(--blue-bg); color: var(--blue-fg); }
.c-purple { background: var(--purple-bg); color: var(--purple-fg); }
.c-pink { background: var(--pink-bg); color: var(--pink-fg); }
.c-gray { background: var(--gray-bg); color: var(--gray-fg); }
.s-red { background: #e5484d; } .s-orange { background: #f76b15; } .s-yellow { background: #e2a336; }
.s-green { background: #30a46c; } .s-teal { background: #12a594; } .s-blue { background: #3e63dd; }
.s-purple { background: #8e4ec6; } .s-pink { background: #d6409f; } .s-gray { background: #8b8d98; }
.project-tag { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* ---------- Boxes (projects, strategies) ---------- */
.box-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-top: 18px; }
.box {
  position: relative; display: flex; flex-direction: column; gap: 6px; min-height: 120px; padding: 16px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-soft);
  color: var(--text); text-decoration: none; cursor: pointer; overflow: hidden; text-align: left;
}
.box:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.box-bar { position: absolute; left: 0; top: 0; right: 0; height: 5px; }
.box-icon { color: var(--accent); margin-top: 4px; }
.box-name { font-weight: 600; font-size: 15px; margin-top: 6px; padding-right: 28px; overflow-wrap: anywhere; }
.box-meta { color: var(--muted); font-size: 12px; margin-top: auto; }
.box-menu { position: absolute; top: 10px; right: 8px; opacity: .7; }
.box:hover .box-menu { opacity: 1; }
.box-new { align-items: center; justify-content: center; border-style: dashed; border-color: var(--border-strong); background: none; color: var(--muted); font-weight: 500; }
.box-new:hover { color: var(--text); box-shadow: none; background: var(--hover); }

/* ---------- Menus ---------- */
.menu {
  position: fixed; z-index: 100; min-width: 190px; max-width: 300px; max-height: 340px; overflow-y: auto;
  padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--elev); box-shadow: var(--shadow);
}
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 5px;
  background: none; color: var(--text); cursor: pointer; text-align: left;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item.danger { color: var(--danger); }
.menu-item .ic { color: var(--muted); }
.menu-item.danger .ic { color: var(--danger); }
.menu-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; }
.menu-check { color: var(--accent); }
.menu-check .ic { color: var(--accent); }
.menu-sep { height: 1px; margin: 4px 2px; background: var(--border); }
.menu-head { padding: 6px 10px 4px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Dialogs ---------- */
.overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; background: rgba(10, 12, 16, .45); }
.dialog { width: min(460px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; border-radius: 12px; background: var(--elev); box-shadow: var(--shadow); border: 1px solid var(--border); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 4px 20px; }
.dialog-head h2 { font-size: 17px; font-weight: 600; }
.dialog-body { padding: 10px 20px; overflow-y: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.dialog-actions .danger { margin-right: auto; }
.dialog-text { margin: 0 0 8px; color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }
.input {
  width: 100%; height: 36px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border-strong);
  background: var(--bg); color: var(--text); font: inherit;
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--active); }
.form-error { margin: 0; color: var(--danger); font-size: 13px; min-height: 0; }
.form-error:empty { display: none; }
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: 8px; background: var(--hover); border: 1px solid var(--border); align-self: flex-start; flex-wrap: wrap; }
.seg-btn { padding: 5px 14px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; font-weight: 500; }
.seg-btn.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 120; transform: translate(-50%, 20px); opacity: 0;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 8px; background: #1e1f21; color: #fff;
  box-shadow: var(--shadow); pointer-events: none; transition: opacity .2s, transform .2s;
}
:root[data-theme="dark"] .toast { background: #f0f0f1; color: #1e1f21; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Strategy board ---------- */
.board-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.board-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
.board-name { border: 0; background: none; font-weight: 600; font-size: 16px; padding: 4px 8px; border-radius: 6px; cursor: pointer; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-name:hover { background: var(--hover); }
.tool-group { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 8px; background: var(--hover); }
.tool { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.tool:hover { color: var(--text); }
.tool.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .18); }
.tool:disabled { opacity: .35; cursor: default; }
.width-dot { display: block; border-radius: 50%; background: currentColor; }
.swatch { width: 22px; height: 22px; margin: 5px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.board-status { font-size: 12px; color: var(--muted); }
.board-scroll {
  flex: 1; min-height: 0; overflow: auto;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dotgrid) 1px, transparent 1px);
  background-size: 22px 22px;
}
.stage { position: relative; touch-action: none; }
.stage canvas { display: block; }
.board-text {
  position: absolute; min-width: 160px; padding: 2px; margin: 0; border: 1px dashed var(--accent); border-radius: 4px;
  background: transparent; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; line-height: 1.25;
  resize: none; outline: none; overflow: hidden; white-space: pre;
}

/* ---------- Login ---------- */
.login { flex: 1; display: grid; place-items: center; padding: 16px; position: relative; background: var(--bg-soft); }
.login-theme { position: absolute; top: 12px; right: 12px; }
.login-card { width: min(380px, 100%); padding: 32px 28px; border-radius: 14px; background: var(--bg); border: 1px solid var(--border); box-shadow: var(--shadow); text-align: center; }
.login-card h1 { font-size: 24px; margin: 10px 0 4px; }
.login-card .form { margin-top: 20px; text-align: left; }
.logo.big { justify-content: center; }
.login-msg:empty { display: none; }
