:root {
  --board: #e8e1d3;
  --board-dot: #d6cdbb;
  --paper: #fffdf8;
  --ink: #2b2622;
  --ink-2: #6b6259;
  --line: #e4ddd0;
  --accent: #2b2622;
  --spark: #ffcc33;
  --red: #e5484d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 6px 18px rgba(60, 40, 20, .10);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background-color: var(--board);
  background-image: radial-gradient(var(--board-dot) 1px, transparent 1.2px);
  background-size: 18px 18px;
  line-height: 1.6;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2 { line-height: 1.3; margin: 0 0 .6em; }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 700; }
code { background: #f1ece2; padding: 1px 6px; border-radius: 6px; }
[hidden] { display: none !important; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 20px 16px 80px; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.center { text-align: center; }
.inline { display: inline; }

/* ---- header ---- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px;
  background: rgba(255, 253, 248, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; text-decoration: none; font-size: 1.05rem; white-space: nowrap; }
.brand-dots { display: flex; }
.brand-dots i { width: 12px; height: 12px; border-radius: 50%; margin-left: -4px; border: 2px solid var(--paper); }
.brand-dots i:first-child { margin-left: 0; }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; padding: 6px 12px; border-radius: 999px; color: var(--ink-2); font-weight: 500; }
.nav a.on { background: var(--ink); color: #fff; }
.nav a:not(.on):hover { background: #f1ece2; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* ---- buttons / form ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 999px;
  border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform .1s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-accent { background: var(--spark); border-color: var(--ink); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 4px 12px; font-size: .85rem; }
.btn-lg { padding: 12px 28px; font-size: 1.05rem; }
.btn-block { width: 100%; padding: 12px; }
.btn-link { background: none; border: 0; font: inherit; color: var(--ink-2); cursor: pointer; text-decoration: underline; padding: 0; }
.btn-link.danger { color: var(--red); }

input, select, textarea {
  font: inherit; color: inherit;
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); }
label { display: block; }
.label, label > input, label > select { display: block; }
.label { font-size: .85rem; font-weight: 700; color: var(--ink-2); margin-bottom: 4px; }
.field { margin-bottom: 16px; }
.field input + input, .field select + input { margin-top: 6px; }
.check { display: inline-flex; gap: 6px; align-items: center; margin-top: 6px; font-size: .9rem; }
.check input { width: auto; }

.panel { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.narrow { max-width: 420px; margin: 40px auto; }
.auth label { margin-bottom: 14px; font-weight: 500; }
.auth label input { margin-top: 4px; }
.flash { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 500; }
.err { color: var(--red); font-weight: 700; }
.errlog { white-space: pre-wrap; background: #fbeeee; padding: 10px; border-radius: 8px; font-size: .8rem; }

/* ---- stage chip ---- */
.chip {
  display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700;
  background: color-mix(in srgb, var(--c) 16%, white); color: color-mix(in srgb, var(--c) 75%, black);
  border: 1.5px solid var(--c);
}

/* ---- stats ---- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; }
.stat b { display: block; font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.stat span { font-size: .78rem; color: var(--ink-2); }

/* ---- spark (描きたいメモ) ---- */
.spark { background: #fff7d6; border: 2px dashed #e8c45a; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 24px; }
.spark-title { display: block; margin-bottom: 8px; }
.spark-row, .log-form, .add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.spark-row select, .log-form select, .log-form input[type="datetime-local"] { width: auto; min-width: 150px; }
.spark-row input:not(.grow), .log-form input:not(.grow):not([type="datetime-local"]) { width: 180px; }
.grow { flex: 1; min-width: 180px; }
.open-logs { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.open-logs li { display: flex; align-items: center; gap: 10px; background: #fff; padding: 6px 8px 6px 12px; border-radius: 10px; }
.open-logs .ago { font-size: .8rem; color: var(--ink-2); min-width: 60px; }
.open-logs .what { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
em { font-style: normal; font-weight: 700; background: #ffe58a; padding: 0 6px; border-radius: 6px; margin-right: 4px; }

/* ---- board ---- */
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; background: var(--paper); padding: 4px; border-radius: 999px; box-shadow: var(--shadow); }
.tabs a { text-decoration: none; padding: 5px 14px; border-radius: 999px; font-weight: 700; font-size: .9rem; color: var(--ink-2); }
.tabs a.on { background: var(--ink); color: #fff; }
.tabs small { opacity: .6; margin-left: 2px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .82rem; font-weight: 700; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; }

.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 28px 24px; }
.empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); }

.stack-card { display: flex; flex-direction: column; }
.stack { position: relative; display: block; height: 270px; text-decoration: none; }
.sheet {
  --k: calc(var(--n) - 1 - var(--i));
  position: absolute; right: 8px; bottom: 6px;
  width: calc(100% - 70px); height: calc(100% - 66px);
  background: var(--paper); border-radius: 8px; overflow: hidden;
  border-top: 6px solid var(--c, #ccc);
  box-shadow: 0 1px 2px rgba(60, 40, 20, .15), 0 4px 12px rgba(60, 40, 20, .12);
  z-index: var(--i);
  transform: translate(calc(var(--k) * -11px), calc(var(--k) * -11px)) rotate(var(--r, 0deg));
  transition: transform .25s cubic-bezier(.3, .7, .4, 1.2);
}
.sheet img { width: 100%; height: 100%; object-fit: cover; }
.sheet .noimg { display: grid; place-items: center; height: 100%; font-weight: 800; font-size: 1.4rem; color: var(--c); background: color-mix(in srgb, var(--c) 8%, white); }
.sheet.blank { --c: #ccc; display: grid; place-items: center; color: var(--ink-2); font-size: .9rem; transform: none; }
.sheet .tag {
  position: absolute; left: 6px; bottom: 6px;
  font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  background: rgba(255, 255, 255, .92); border-left: 4px solid var(--c);
}
.sheet:not(:last-of-type) .tag { opacity: 0; transition: opacity .2s; }
.stack:hover .sheet { transform: translate(calc(var(--k) * -30px), calc(var(--k) * -6px)) rotate(calc(var(--k) * -2deg)); }
.stack:hover .sheet .tag { opacity: 1; }
.stack .more { position: absolute; left: 0; top: 0; z-index: 20; background: var(--ink); color: #fff; font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; }

.stack-info { background: var(--paper); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px; margin-top: 6px; }
.stack-info h2 { font-size: 1rem; margin: 0 0 6px; display: flex; gap: 6px; align-items: center; }
.stack-info h2 a { text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: #efe9de; gap: 2px; }
.progress i { display: block; }
.meta { color: var(--ink-2); font-size: .82rem; margin: 6px 0 8px; }
.status { font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: #efe9de; flex-shrink: 0; }
.status.s-done { background: #d9f2e3; color: #1d6b40; }

/* ---- entry form ---- */
.form-panel { max-width: 760px; margin: 0 auto 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.stage-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.stage-opt { position: relative; }
.stage-opt input { position: absolute; left: 0; top: 0; opacity: 0; pointer-events: none; }
.stage-opt span {
  display: inline-block; padding: 8px 16px; border-radius: 999px; cursor: pointer; font-weight: 700;
  border: 2px solid var(--c); color: color-mix(in srgb, var(--c) 75%, black); background: #fff;
  transition: background .15s;
}
.stage-opt input:checked + span { background: var(--c); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--c) 60%, black); }
.stage-opt input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }
.quick { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.quick button { font: inherit; font-size: .78rem; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.quick button.on, .quick button:hover { border-color: var(--ink); }
.dropzone {
  position: relative; display: grid; place-items: center; min-height: 180px; cursor: pointer;
  border: 2px dashed #cfc5b3; border-radius: 12px; background: #faf7f0; overflow: hidden; text-align: center; color: var(--ink-2);
}
.dropzone.over { border-color: var(--ink); background: #f1ece2; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone img { max-height: 420px; width: auto; }
.trigger-box { border: 2px solid #f0d77a; background: #fffbea; border-radius: 12px; padding: 12px 16px 2px; margin: 0 0 16px; }
.trigger-box legend { font-weight: 800; padding: 0 6px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.danger-zone { text-align: right; margin-top: 20px; }

/* ---- work page ---- */
.work-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 18px; }
.work-head .back { text-decoration: none; font-weight: 700; color: var(--ink-2); }
.work-edit { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 280px; }
.title-input { font-size: 1.3rem; font-weight: 800; background: transparent; border-color: transparent; padding: 4px 8px; }
.title-input:hover { border-color: var(--line); background: #fff; }
.work-edit select { width: auto; }
.work-head .meta { width: 100%; margin: 0; order: 3; }
.flip { display: flex; flex-direction: column; align-items: center; }
.flip-view { position: relative; width: 100%; display: grid; }
.flip-frame { grid-area: 1 / 1; margin: 0; opacity: 0; transition: opacity .2s; display: flex; flex-direction: column; align-items: center; }
.flip-frame.on { opacity: 1; }
.flip-frame img { max-height: 60vh; width: auto; border-radius: 8px; border-top: 6px solid var(--c); }
.flip-frame figcaption { margin-top: 8px; font-size: .9rem; }
.flip-range { width: min(500px, 100%); margin-top: 12px; font-size: .85rem; color: var(--ink-2); text-align: center; }
.flip-range input { padding: 0; accent-color: var(--ink); border: 0; }

.timeline { display: grid; gap: 14px; }
.layer {
  display: grid; grid-template-columns: 160px 1fr; gap: 16px;
  background: var(--paper); border-radius: 12px; box-shadow: var(--shadow); padding: 12px;
  border-left: 8px solid var(--c);
}
.layer-img .gallery.n1 img { height: 160px; }
.layer-img .noimg { display: grid; place-items: center; width: 160px; height: 110px; background: #f4efe6; border-radius: 8px; color: var(--ink-2); font-size: .85rem; }
.layer-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.layer-top time { font-weight: 700; }
.layer-top .edit { margin-left: auto; font-size: .85rem; color: var(--ink-2); }
.layer p { margin: 8px 0 0; }
.trig { background: #fffbea; border-radius: 8px; padding: 6px 10px; font-size: .9rem; }
.delay { display: inline-block; margin-left: 6px; font-size: .78rem; padding: 0 8px; background: #fff; border-radius: 999px; border: 1px solid #f0d77a; }
.memo { white-space: normal; font-size: .92rem; }

/* ---- calendar ---- */
.cal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-head h1 { margin: 0; min-width: 140px; text-align: center; }
.cal-head .meta { margin: 0 0 0 auto; }
.cal-layout { display: grid; grid-template-columns: 1fr 280px; gap: 20px; align-items: start; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dow { text-align: center; font-weight: 700; font-size: .8rem; color: var(--ink-2); }
.sun { color: #d0453c; }
.sat { color: #3b6fd8; }
.day {
  position: relative; aspect-ratio: 1 / 1.05; min-height: 70px;
  background: rgba(255, 253, 248, .6); border-radius: 10px; text-decoration: none; overflow: hidden;
  border: 2px solid transparent;
}
.day.pad { background: transparent; }
.day.has { background: var(--paper); box-shadow: var(--shadow); }
.day.today { border-color: var(--ink); }
.day.sel { border-color: var(--spark); box-shadow: 0 0 0 3px var(--spark); }
.day .num { position: absolute; top: 4px; left: 7px; z-index: 2; font-weight: 800; font-size: .85rem; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.day img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.day .bars { position: absolute; left: 4px; right: 4px; bottom: 4px; height: 7px; display: flex; gap: 2px; border-radius: 4px; overflow: hidden; z-index: 2; }
.day .bars i { display: block; }
.day .mins { position: absolute; right: 5px; bottom: 13px; z-index: 2; font-size: .68rem; font-weight: 700; background: rgba(255, 255, 255, .9); padding: 0 5px; border-radius: 6px; }
.cal-side { position: sticky; top: 76px; }
.hbar { display: grid; grid-template-columns: 110px 1fr 70px; align-items: center; gap: 8px; margin-bottom: 10px; font-size: .85rem; }
.hbar-label { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.hbar-label i { width: 10px; height: 10px; border-radius: 3px; }
.hbar-track { height: 10px; background: #efe9de; border-radius: 999px; overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: 999px; }
.hbar-val { text-align: right; color: var(--ink-2); }
.day-list { margin-top: 20px; }
.day-list .layer { box-shadow: none; border: 1px solid var(--line); border-left: 8px solid var(--c); margin-bottom: 10px; }

/* ---- triggers ---- */
.page-title { margin-bottom: 4px; }
.lead { color: var(--ink-2); margin: 0 0 18px; }
.insights { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.insight { background: #fff7d6; border: 2px solid #f0d77a; border-radius: var(--radius); padding: 12px 16px; }
.insight span { display: block; font-size: .8rem; color: var(--ink-2); }
.insight b { display: block; font-size: 1.2rem; }
.insight small { color: var(--ink-2); }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.ttable { width: 100%; border-collapse: collapse; font-size: .88rem; margin-bottom: 12px; }
.ttable th { text-align: left; font-size: .75rem; color: var(--ink-2); padding: 4px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ttable td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.ttable .rename input { border-color: transparent; padding: 4px 6px; font-weight: 700; min-width: 140px; }
.ttable .rename input:hover, .ttable .rename input:focus { border-color: var(--line); }
.minibar { display: inline-block; width: 50px; height: 6px; background: #efe9de; border-radius: 999px; overflow: hidden; margin-right: 6px; vertical-align: middle; }
.minibar i { display: block; height: 100%; background: var(--spark); }
.hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; height: 140px; align-items: end; }
.hour { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.hour i { display: block; background: var(--ink); border-radius: 3px 3px 0 0; min-height: 2px; }
.hour span { font-size: .65rem; text-align: center; color: var(--ink-2); height: 14px; }
.log-list { list-style: none; padding: 0; margin: 14px 0 0; }
.log-list li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.log-list time { font-size: .82rem; color: var(--ink-2); min-width: 130px; }
.log-list .what { flex: 1; }
.log-list li.drawn .what { color: var(--ink-2); }
.badge { font-size: .78rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; text-decoration: none; }
.badge.ok { background: #d9f2e3; color: #1d6b40; }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .cal-layout, .two-col { grid-template-columns: 1fr; }
  .cal-side { position: static; }
  .insights { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .nav { order: 3; width: 100%; justify-content: space-between; }
  .nav a { flex: 1; text-align: center; }
  .top-actions .btn { padding: 6px 12px; font-size: .85rem; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 8px 10px; }
  .stat b { font-size: 1.05rem; }
  .stat span { font-size: .68rem; }
  .grid2 { grid-template-columns: 1fr; }
  .board { grid-template-columns: 1fr 1fr; gap: 20px 12px; }
  .stack { height: 200px; }
  .sheet { width: calc(100% - 44px); height: calc(100% - 46px); transform: translate(calc(var(--k) * -7px), calc(var(--k) * -7px)) rotate(var(--r, 0deg)); }
  .stack:hover .sheet { transform: translate(calc(var(--k) * -7px), calc(var(--k) * -7px)) rotate(var(--r, 0deg)); }
  .layer { grid-template-columns: 96px 1fr; gap: 10px; }
  .layer-img .gallery.n1 img { height: 96px; }
  .layer-img .noimg { width: 96px; height: 70px; }
  .calendar { gap: 3px; }
  .day { min-height: 0; border-radius: 6px; }
  .day .mins { display: none; }
  .cal-head .meta { width: 100%; margin: 0; }
  .ttable th:nth-child(3), .ttable td:nth-child(3) { display: none; }
  .ttable { display: block; overflow-x: auto; }
  .panel { padding: 16px; }
  .log-list li { flex-wrap: wrap; }
  .log-list time { min-width: 0; width: 100%; }
  .spark-row select, .spark-row input { width: 100% !important; }
}

.two-col > *, .cal-layout > * { min-width: 0; }

/* ---- 学習メモ ---- */
.notes-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.note-form-panel { max-width: 760px; margin: 0 auto 24px; }
.dropzone-sm { min-height: 110px; }
.tag-suggest button { color: var(--ink-2); }
.notes-filter { margin-bottom: 18px; }
.note-search { display: flex; gap: 8px; max-width: 460px; margin-bottom: 10px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fchip {
  text-decoration: none; font-size: .85rem; font-weight: 700; padding: 3px 12px; border-radius: 999px;
  background: var(--paper); box-shadow: var(--shadow); color: var(--ink-2);
}
.fchip small { opacity: .6; }
.fchip.on { background: var(--ink); color: #fff; }
.fchip.stagechip { border-left: 6px solid var(--c); }
.fchip.stagechip.on { background: var(--c); }

.notes-board { columns: 4 250px; column-gap: 20px; }
.notes-board .empty { column-span: all; }
.note {
  position: relative; break-inside: avoid; margin: 0 0 20px;
  background: color-mix(in srgb, var(--c) 7%, var(--paper));
  border-radius: 6px; border-top: 6px solid var(--c);
  box-shadow: 0 1px 2px rgba(60, 40, 20, .12), 0 6px 16px rgba(60, 40, 20, .10);
  transform: rotate(var(--r, 0deg));
  transition: transform .2s;
}
.note:hover { transform: rotate(0deg) translateY(-2px); }
.note.pinned { box-shadow: 0 0 0 2px var(--spark), 0 6px 16px rgba(60, 40, 20, .14); }
.pin-form { position: absolute; top: -14px; right: 10px; z-index: 2; }
.pin { border: 0; background: none; font-size: 1.25rem; cursor: pointer; padding: 0; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25)); }
.note:not(.pinned) .pin { opacity: .35; }
.note:not(.pinned):hover .pin { opacity: 1; }
.note-img img { width: 100%; max-height: 220px; object-fit: cover; }
.note-body { padding: 12px 14px 10px; }
.note-body h2 { font-size: 1rem; margin: 0 0 6px; }
.note-text { font-size: .9rem; line-height: 1.7; word-break: break-word; }
.note-text a { color: #3b6fd8; }
.note-text.clamped { max-height: 9.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.note-text.clamped.open { max-height: none; -webkit-mask-image: none; mask-image: none; }
[data-clamp] { max-height: 9.5em; overflow: hidden; }
[data-clamp].open { max-height: none; }
.more-btn { display: block; font-size: .8rem; margin-top: 2px; }
.note-url { display: inline-block; margin-top: 8px; font-size: .82rem; color: #3b6fd8; text-decoration: none; word-break: break-all; }
.note-foot { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: 10px; }
.ntag { font-size: .78rem; font-weight: 700; color: var(--ink-2); text-decoration: none; }
.ntag:hover { color: var(--ink); }
.note-meta { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 6px; border-top: 1px dashed color-mix(in srgb, var(--c) 35%, transparent); font-size: .75rem; color: var(--ink-2); }
@media (max-width: 640px) {
  .notes-board { columns: 1; }
  .note { transform: none; }
  .nav a { padding: 6px 4px; font-size: .9rem; }
}

/* ---- 複数画像 ---- */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-bottom: 8px; }
.img-grid:empty { display: none; }
.img-item { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #f1ece2; }
.img-item img { width: 100%; height: 100%; object-fit: cover; }
.img-item.removing img { opacity: .25; filter: grayscale(1); }
.img-item.new { outline: 2px dashed var(--ink-2); outline-offset: -2px; }
.cover-pick, .remove-pick { position: absolute; top: 4px; cursor: pointer; font-size: .7rem; font-weight: 700; }
.cover-pick { left: 4px; }
.remove-pick { right: 4px; }
.cover-pick input, .remove-pick input { position: absolute; opacity: 0; pointer-events: none; }
.cover-pick span { display: block; padding: 0 6px; border-radius: 999px; background: rgba(255, 255, 255, .85); color: var(--ink-2); }
.cover-pick input:checked + span { background: var(--spark); color: var(--ink); }
.remove-pick span, .remove-new {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: rgba(43, 38, 34, .75); color: #fff; font-size: .85rem; border: 0; cursor: pointer; padding: 0;
}
.remove-new { position: absolute; top: 4px; right: 4px; }
.remove-pick input:checked + span { background: var(--red); }
.dropzone-multi { min-height: 96px; margin-bottom: 8px; }
.img-count { margin: 4px 0 0; }
.img-count.over { color: var(--red); font-weight: 700; }

.gallery { display: grid; gap: 3px; border-radius: 8px; overflow: hidden; width: 160px; }
.gallery .g-item { position: relative; display: block; background: #f1ece2; }
.gallery .g-item:nth-child(n+5) { display: none; }
.gallery img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 1; }
.gallery.n1 img { aspect-ratio: auto; height: 160px; }
.gallery.n2, .gallery.n3, .gallery.n4 { grid-template-columns: 1fr 1fr; }
.gallery.n3 .g-item:first-child { grid-column: span 2; }
.gallery.n3 .g-item:first-child img { aspect-ratio: 2 / 1; }
.g-more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(43, 38, 34, .55); color: #fff; font-weight: 800; font-size: 1.1rem; }
.layer-img .gallery { width: 160px; }
.note-gallery { width: 100%; border-radius: 0; }
.note-gallery.n1 img { height: auto; max-height: 220px; }
@media (max-width: 640px) {
  .layer-img .gallery { width: 96px; }
  .layer-img .gallery.n1 img { height: 96px; }
}

.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(20, 16, 12, .9); display: grid; place-items: center; }
.lightbox img { max-width: 92vw; max-height: 86vh; border-radius: 6px; }
.lightbox button { position: absolute; border: 0; background: rgba(255, 255, 255, .12); color: #fff; font-size: 2rem; width: 52px; height: 52px; border-radius: 50%; cursor: pointer; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-close { top: 16px; right: 16px; font-size: 1.6rem !important; }
.lightbox.single .lb-prev, .lightbox.single .lb-next { display: none; }
.lb-count { position: absolute; bottom: 18px; color: #fff; font-weight: 700; font-size: .9rem; }

/* ---- 分類・毎日の練習 ---- */
.cat-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -4px 0 18px; position: relative; }
.fchip.catchip { border-left: 6px solid var(--cc); }
.fchip.catchip.on { background: var(--cc); color: #fff; }
.cat-chip { font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; color: var(--cc); border: 1.5px solid var(--cc); flex-shrink: 0; }
.cat-manage summary { list-style: none; cursor: pointer; }
.cat-manage summary::-webkit-details-marker { display: none; }
.cat-panel { position: absolute; z-index: 30; left: 0; top: calc(100% + 6px); width: min(520px, 100%); margin: 0; }
.cat-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cat-edit { display: flex; align-items: center; gap: 8px; flex: 1; }
.cat-edit input[type="color"] { width: 38px; height: 34px; padding: 2px; flex-shrink: 0; }
.cat-edit input[name="name"] { flex: 1; min-width: 0; padding: 6px 10px; }
.cat-edit .check { margin: 0; white-space: nowrap; }
.cat-add { padding-top: 10px; border-top: 1px dashed var(--line); margin-bottom: 6px; }
.new-work { display: flex; gap: 8px; margin-top: 6px; }
.new-work select { width: auto; flex-shrink: 0; }
.new-work[hidden] { display: none !important; }
.work-edit select { width: auto; }

.daily {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px 18px;
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  border-left: 8px solid var(--cc); padding: 12px 16px; margin-bottom: 14px;
}
.daily-head { display: flex; flex-direction: column; gap: 2px; min-width: 150px; }
.daily-streak { font-size: 1.3rem; font-weight: 800; line-height: 1.2; color: var(--cc); }
.daily-today { font-size: .8rem; color: var(--ink-2); font-weight: 700; }
.daily:not(.done) .daily-today { color: var(--red); }
.daily-days { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.dd { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dd i { display: block; width: 100%; max-width: 30px; aspect-ratio: 1; border-radius: 8px; background: #efe9de; }
.dd.on i { background: var(--cc); }
.dd.today i { outline: 2px solid var(--ink); outline-offset: 1px; }
.dd small { font-size: .62rem; color: var(--ink-2); }
.daily-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
@media (max-width: 640px) {
  .daily { grid-template-columns: 1fr auto; }
  .daily-days { grid-column: 1 / -1; grid-row: 2; gap: 2px; }
  .daily-head { min-width: 0; }
  .dd i { border-radius: 4px; }
  .cat-panel { position: static; margin-top: 8px; width: 100%; }
  .cat-manage[open] { width: 100%; }
  .cat-edit { flex-wrap: wrap; }
}
.stack-cat { margin-bottom: 4px; display: flex; }

/* ---- トリガーメモ ---- */
.rule-card {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  border-left: 8px solid var(--spark); padding: 12px 16px; margin-bottom: 14px;
}
.rule-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.rule-body {  line-height: 1.7;    font-size: 20px;
    font-weight: 700;
    margin-top: 20px; }
    @media (max-width: 640px) {
      .rule-body {  line-height: 1.7;    font-size: 18px; }
    }
.rules-panel { border-left: 8px solid var(--spark); }

/* ---- 使い方 ---- */
.toc ol { margin: 6px 0 0; padding-left: 1.4em; columns: 2 240px; }
.toc li { margin-bottom: 2px; }
.toc a { text-decoration: none; color: var(--ink-2); font-weight: 500; }
.toc a:hover { color: var(--ink); text-decoration: underline; }
.guide section { scroll-margin-top: 80px; }
#rules { scroll-margin-top: 80px; }
.guide h3 { font-size: 1rem; margin: 18px 0 6px; }
.guide p, .guide li, .guide dd { line-height: 1.8; }
.guide ul, .guide ol { padding-left: 1.4em; }
.steps li { margin-bottom: 10px; }
.color-list { list-style: none; padding: 0 !important; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.color-list i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 6px; vertical-align: -2px; }
.tab-desc dt, .faq dt { font-weight: 800; margin-top: 14px; }
.tab-desc dt::before { content: "▸ "; color: var(--ink-2); }
.faq dt::before { content: "Q. "; color: var(--ink-2); }
.tab-desc dd, .faq dd { margin: 4px 0 0 1em; }
.tab-desc dd ul { margin: 4px 0; }
@media (max-width: 640px) {
  .nav { overflow-x: auto; }
  .nav a { flex: 0 0 auto; padding: 6px 10px; }
}

/* ---- 次にやること ---- */
.next-link, .next-empty { display: block; text-decoration: none; margin: 2px 0 8px; }
.next-box { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.next-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .85rem; font-weight: 800; padding: 3px 12px 3px 4px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, white); color: color-mix(in srgb, var(--c) 78%, black);
  border: 2px solid var(--c);
}
.next-tag b, .next-only {
  font-size: .68rem; font-weight: 800; color: #fff; background: var(--c); padding: 0 7px; border-radius: 999px; line-height: 1.6;
}
.next-only { margin-right: 6px; }
.next-memo { font-size: .8rem; color: var(--ink); background: #fff7d6; border-radius: 6px; padding: 2px 8px; line-height: 1.5; word-break: break-word; }
.next-link:hover .next-tag { filter: brightness(.96); }
.next-empty { font-size: .8rem; color: var(--ink-2); }
.next-empty:hover { color: var(--ink); text-decoration: underline; }
.next-fields { border: 2px solid var(--line); background: #faf7f0; border-radius: 12px; padding: 12px 16px 10px; margin: 0 0 16px; }
.next-fields legend { font-weight: 800; padding: 0 6px; }
.next-fields .stage-opt span { padding: 5px 12px; font-size: .88rem; }
.next-panel { padding: 14px 18px; }
.next-panel .next-current { margin-bottom: 6px; }
.next-panel .next-tag { font-size: 1rem; }
.next-panel summary { cursor: pointer; display: inline-block; margin-bottom: 4px; }
.next-panel form .next-fields { margin-top: 8px; }

/* ---- 作業タグ編集 ---- */
.legend { position: relative; align-items: center; }
.stage-manage .cat-panel { left: auto; right: 0; width: min(560px, 92vw); }
.stage-rows-head { display: grid; grid-template-columns: 38px 1fr 110px 60px; gap: 8px; margin: 4px 0 4px; font-weight: 700; }
.stage-panel .short-in { width: 110px !important; flex: 0 0 110px; padding: 6px 8px; }
.stage-panel .cat-edit input[name="label"] { flex: 1; }
.hidden-stages { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.hidden-stages .chip { cursor: pointer; opacity: .7; font: inherit; font-size: .78rem; font-weight: 700; }
@media (max-width: 640px) {
  .legend { width: 100%; }
  .stage-manage { width: 100%; }
  .stage-manage .cat-panel { position: static; width: 100%; }
  .stage-panel .short-in { flex-basis: 80px; width: 80px !important; }
  .stage-rows-head { display: none; }
}
