:root {
  color-scheme: light;
  --ink: #18324a;
  --ink-muted: #516171;
  --amber: #d49a32;
  --amber-soft: #f7e9c8;
  --paper: #fffdf8;
  --canvas: #f2efe7;
  --rule: #d7d3c8;
  --success: #2d6a4f;
  --success-soft: #e7f1eb;
  --risk: #a34532;
  --risk-soft: #f8e8e3;
  --focus: #2a6d9b;
  --shadow: 0 8px 24px rgba(24, 50, 74, .10);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  line-height: 1.55;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--canvas); scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
.login-shell { width: min(30rem, calc(100% - 2rem)); margin: 10vh auto; }
::selection { background: var(--amber); color: #172a3b; }
button, input, textarea, select { font: inherit; }
button, .file-button { min-height: 44px; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 20; padding: .65rem 1rem; background: var(--ink); color: white; }
.skip-link:focus { top: 1rem; }

.topbar { min-height: 104px; padding: 1.15rem clamp(1rem, 4vw, 4rem); background: var(--ink); color: white; display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.product-name { margin: 0; font-size: clamp(1.25rem, 3vw, 1.75rem); font-weight: 800; letter-spacing: -.025em; }
.product-sub { margin: .15rem 0 0; color: #d8e1e8; font-size: .9rem; }
.system-state { display: grid; grid-template-columns: auto auto; gap: 0 .55rem; align-items: center; font-size: .78rem; color: #d8e1e8; }
.system-state span:last-child { grid-column: 2; }
.local-dot { width: .7rem; height: .7rem; background: #78c39b; border-radius: 50%; box-shadow: 0 2px 8px rgba(120, 195, 155, .4); }

.tabs { padding: 0 clamp(1rem, 4vw, 4rem); display: flex; overflow-x: auto; background: var(--paper); border-bottom: 1px solid var(--rule); scrollbar-color: var(--amber) transparent; }
.tabs button { flex: 0 0 auto; padding: .8rem .9rem .65rem; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--ink-muted); font-weight: 700; }
.tabs button[aria-current="page"] { color: var(--ink); border-bottom-color: var(--amber); }

main { width: min(1360px, 100%); margin: 0 auto; padding: clamp(1.25rem, 3vw, 3rem) clamp(1rem, 4vw, 4rem) 5rem; }
.view:not(.active) { display: none; }
.view.active { animation: settle .28s cubic-bezier(.2,.8,.2,1); }
@keyframes settle { from { opacity: .3; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(1.75rem, 5vw, 3.4rem); line-height: 1.06; letter-spacing: -.035em; text-wrap: balance; }
h2 { margin: 0 0 .7rem; font-size: 1.12rem; letter-spacing: -.015em; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 1.5rem; margin-bottom: 1.8rem; }
.section-heading p { max-width: 68ch; margin: .65rem 0 0; color: var(--ink-muted); }
.save-state { flex: 0 0 auto; color: var(--success); font-weight: 700; font-size: .85rem; padding: .4rem .7rem; background: var(--success-soft); border-radius: 999px; }
.save-state.saving { color: #705218; background: var(--amber-soft); }

.week-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, .8fr); gap: clamp(1rem, 3vw, 2.5rem); align-items: start; }
.weekly-sheet { background: var(--paper); padding: clamp(1rem, 3vw, 2.25rem); box-shadow: var(--shadow); border-radius: 16px; }
.weekly-sheet fieldset { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0 0; padding: 1.6rem 0 0; }
.weekly-sheet legend { padding: 0; font-weight: 800; font-size: 1.05rem; }
.week-meta, .plan-grid, .range-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.plan-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.decision-block textarea { min-height: 116px; border-color: #c08a2b; background: #fffbf0; }
label { display: grid; gap: .4rem; font-weight: 700; font-size: .86rem; }
input, textarea, select { width: 100%; color: var(--ink); background: white; border: 1px solid #aeb7be; border-radius: 10px; padding: .72rem .8rem; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #596d7d; opacity: 1; }
.check { display: flex; flex-direction: row; align-items: center; gap: .55rem; min-height: 44px; margin-top: .8rem; font-weight: 600; }
.check input, .choice-row input { width: 1.1rem; height: 1.1rem; accent-color: var(--ink); }
.choice-row { display: flex; flex-wrap: wrap; gap: .65rem 1rem; margin-bottom: .9rem; }
.choice-row label { display: flex; align-items: center; gap: .45rem; min-height: 44px; font-weight: 600; }
.field-note { margin: .55rem 0 0; color: var(--ink-muted); font-size: .8rem; font-weight: 500; }
.reflection { margin-top: 1.6rem; border-top: 1px solid var(--rule); padding-top: 1rem; }
.reflection summary { cursor: pointer; font-weight: 800; }
.reflection[open] summary { margin-bottom: 1rem; }
input[type="range"] { padding: 0; accent-color: var(--amber); }
.range-grid + label { margin-top: 1rem; }

.week-side { display: grid; gap: 1rem; }
.readiness, .boundary-note, .automation-note { padding: 1.2rem; background: rgba(255,253,248,.76); border-top: 4px solid var(--ink); }
.readiness.ready { border-top-color: var(--success); }
.readiness h2 { font-size: 1.25rem; }
.readiness ul { padding-left: 1.2rem; margin-bottom: 0; }
.readiness li + li { margin-top: .45rem; }
.boundary-note dl { margin: 0; }
.boundary-note dl div { display: grid; grid-template-columns: 4rem 1fr; gap: .7rem; padding: .65rem 0; border-bottom: 1px solid var(--rule); }
.boundary-note dl div:last-child { border: 0; }
.boundary-note dt { font-weight: 800; }
.boundary-note dd { margin: 0; color: var(--ink-muted); }
.automation-note { border-top-color: var(--amber); }
.automation-note p { margin: .35rem 0 0; color: var(--ink-muted); }

.primary { background: var(--ink); color: white; border-color: var(--ink); }
button, .file-button { border: 1px solid #9aa7b1; border-radius: 10px; background: var(--paper); color: var(--ink); padding: .62rem .9rem; font-weight: 750; }
button:hover, .file-button:hover { border-color: var(--ink); }
.notice { margin-bottom: 1.6rem; padding: 1rem 1.15rem; background: var(--amber-soft); border-radius: 12px; }
.notice.private { background: #e8eff4; }

.owner-focus { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .8fr); gap: 1.5rem; align-items: center; padding: 1.35rem 1.5rem; margin: 0 0 1.6rem; color: white; background: var(--ink); border-radius: 14px; box-shadow: 0 10px 30px rgba(24,50,74,.16); }
.owner-focus h2 { margin-bottom: .35rem; font-size: 1.35rem; }
.owner-focus p { margin: 0; color: #d8e1e8; }
.desk-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: rgba(255,255,255,.22); }
.desk-summary div { display: grid; justify-items: center; padding: .65rem .35rem; background: var(--ink); }
.desk-summary strong { color: #f5c76d; font-size: 1.55rem; font-variant-numeric: tabular-nums; }
.desk-summary span { font-size: .72rem; color: #d8e1e8; }
.desk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem 2rem; }
.desk-lane { min-width: 0; padding-top: 1rem; border-top: 3px solid var(--ink); }
.desk-lane:nth-child(3) { border-top-color: var(--amber); }
.account-lane { border-top-color: var(--success); }
.task-list, .production-work-list.list { display: grid; gap: .65rem; }
.task-list:empty::before, .production-work-list:empty::before, .work-column:empty::before { content: "現在の記録はありません。マナが正本へ追加するとここに表示されます。"; display: block; padding: 1rem 0; color: var(--ink-muted); border-bottom: 1px dashed #9aa7b1; }
.task-row { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--rule); }
.task-row.is-blocked { background: linear-gradient(90deg, var(--risk-soft), transparent 70%); }
.task-main { min-width: 0; flex: 1; }
.task-row h3 { margin: 0; font-size: 1rem; }
.task-row p { margin: .35rem 0; color: var(--ink-muted); font-size: .82rem; }
.task-row details { flex-basis: 100%; }
.task-row summary { cursor: pointer; font-size: .82rem; font-weight: 750; }
.task-row .url-proof, .production-details > summary { display: inline-flex; align-items: center; min-height: 44px; }
.lane-note { margin: 0; padding: 1rem 0; color: var(--ink-muted); font-size: .82rem; border-bottom: 1px dashed #9aa7b1; }
.checked-copy { font-variant-numeric: tabular-nums; }
.plain-checklist { padding-left: 1.2rem; font-size: .82rem; }
.plain-checklist .done { color: var(--success); text-decoration: line-through; }
.production-details { margin-top: 2.3rem; padding-top: 1.1rem; border-top: 1px solid var(--rule); }
.production-details > summary { cursor: pointer; font-weight: 800; font-size: 1.05rem; }
.production-details[open] > summary { margin-bottom: 1rem; }
.production-tools { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: center; margin-bottom: 1rem; }
.production-tools div { display: grid; min-width: 6rem; }
.production-tools strong { font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.production-tools span, .production-tools p { color: var(--ink-muted); font-size: .78rem; }
.production-tools p { max-width: 55ch; margin: 0; }
.production-work-list.board { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: 1rem; margin-top: 1rem; overflow-x: auto; }
.work-column { min-width: 230px; }
.production-work-list.list { margin-top: 1rem; }
.production-work-list.list .task-row { flex-wrap: wrap; }

.board { display: grid; grid-template-columns: repeat(5, minmax(230px, 1fr)); gap: .85rem; overflow-x: auto; padding: .25rem .1rem 1rem; scroll-snap-type: x proximity; }
.board-column { min-width: 230px; scroll-snap-align: start; }
.column-heading { display: flex; align-items: baseline; justify-content: space-between; padding: 0 .25rem .55rem; }
.column-heading h2 { margin: 0; font-size: .95rem; }
.count { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.post-card, .record-card { background: var(--paper); border-radius: 14px; padding: 1rem; box-shadow: 0 5px 18px rgba(24,50,74,.08); }
.post-card + .post-card, .record-card + .record-card { margin-top: .7rem; }
.post-card h3, .record-card h3 { margin: 0; font-size: 1rem; }
.post-card p, .record-card p { margin: .55rem 0; font-size: .84rem; color: var(--ink-muted); }
.badge-row { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .6rem; }
.badge { display: inline-flex; padding: .2rem .5rem; border-radius: 999px; background: #e8edf0; font-size: .72rem; font-weight: 750; }
.badge.ok { color: var(--success); background: var(--success-soft); }
.badge.warn { color: #6c4f14; background: var(--amber-soft); }
.badge.risk { color: var(--risk); background: var(--risk-soft); }
.card-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .85rem; }
.card-actions button { min-height: 44px; padding: .42rem .65rem; font-size: .78rem; }
.url-proof { display: block; color: var(--success); font-size: .78rem; overflow-wrap: anywhere; }
.validation-copy { color: var(--risk) !important; font-weight: 700; }
.post-search { display: grid; gap: .4rem; max-width: 36rem; margin: 0 0 1rem; font-weight: 700; }
.brand-review { margin: .75rem 0; padding: .7rem; border: 1px solid var(--rule); border-radius: 12px; background: #fffaf2; }
.brand-review summary { cursor: pointer; font-weight: 750; }
.brand-review ul { margin: .65rem 0; padding-left: 1.2rem; }
.draft-preview { margin-top: .8rem; padding-top: .7rem; border-top: 1px solid var(--rule); }
.draft-preview summary { cursor: pointer; font-weight: 750; }
.draft-preview pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: .82rem; color: var(--ink); }

.split-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.workspace-section { margin-top: 1rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
.subheading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .85rem; }
.subheading h2 { margin: 0; }
.record-list:empty::before { content: "まだ記録はありません。必要になった時だけ追加できます。"; display: block; padding: 1.2rem; border: 1px dashed #9aa7b1; border-radius: 12px; color: var(--ink-muted); }
.record-card dl { margin: .7rem 0 0; display: grid; grid-template-columns: max-content 1fr; gap: .3rem .7rem; font-size: .8rem; }
.record-card dd { min-width: 0; overflow-wrap: anywhere; }
.record-card dt { font-weight: 800; }
.record-card dd { margin: 0; color: var(--ink-muted); }
.stacked-form { display: grid; gap: 1rem; }
.standard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.standard-grid label { display: grid; gap: .35rem; font-weight: 700; }
.standard-actions { grid-column: 1 / -1; }
.data-tools { margin-top: 2.5rem; }
.tool-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.file-button { display: inline-flex; align-items: center; cursor: pointer; }
.file-button input { position: absolute; width: 1px; height: 1px; clip: rect(0,0,0,0); }
.integration-status { margin-top: 1.2rem; display: grid; grid-template-columns: minmax(9rem, 1fr) auto; max-width: 34rem; }
.integration-status span, .integration-status strong { padding: .55rem 0; border-bottom: 1px solid var(--rule); }
.integration-status strong { color: var(--risk); font-size: .8rem; }
.hub-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.hub-summary article { display: grid; gap: .15rem; padding: 1rem; background: var(--paper); border-top: 4px solid var(--ink); border-radius: 10px; box-shadow: 0 4px 14px rgba(24,50,74,.07); }
.hub-summary strong { font-size: 1.55rem; font-variant-numeric: tabular-nums; }
.hub-summary span { color: var(--ink-muted); font-size: .78rem; font-weight: 700; }
.calendar-list { display: grid; gap: .55rem; }
.calendar-item { display: grid; grid-template-columns: 9.5rem 1fr; gap: .8rem; padding: .8rem 1rem; background: var(--paper); border-radius: 10px; }
.calendar-item time { font-size: .78rem; font-weight: 800; }
.calendar-item div { display: grid; gap: .2rem; }
.calendar-item span { color: var(--ink-muted); font-size: .78rem; }
.view-toggle { display: flex; gap: .35rem; }
.view-toggle button { min-height: 40px; padding: .35rem .7rem; }

dialog { width: min(620px, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); overflow: auto; border: 0; border-radius: 16px; padding: 0; background: var(--paper); color: var(--ink); box-shadow: 0 18px 60px rgba(15,31,45,.28); }
dialog::backdrop { background: rgba(15,31,45,.55); }
#editor-form { padding: 1.2rem; }
.dialog-heading, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dialog-heading { margin-bottom: 1.1rem; }
.dialog-heading h2 { margin: 0; }
.dialog-heading button { min-height: 44px; }
#dialog-fields { display: grid; gap: .9rem; }
.dialog-actions { justify-content: flex-end; margin-top: 1.2rem; }
.form-error { min-height: 1.2rem; color: var(--risk); font-weight: 700; }
.success-copy { min-height: 1.2rem; color: var(--success); font-weight: 700; }
.eyebrow { margin: 0 0 .5rem; color: var(--ink-muted); font-size: .75rem; font-weight: 800; letter-spacing: .12em; }
.button-link { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; width: fit-content; padding: .62rem .9rem; border: 1px solid #9aa7b1; border-radius: 10px; background: var(--paper); color: var(--ink); font-weight: 750; text-decoration: none; }
.button-link:hover { border-color: var(--ink); }
.security-settings p { max-width: 68ch; color: var(--ink-muted); }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 1rem; transform: translate(-50%, 1rem); opacity: 0; pointer-events: none; background: var(--ink); color: white; padding: .7rem 1rem; border-radius: 10px; box-shadow: var(--shadow); transition: .2s ease-out; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 880px) {
  .topbar { align-items: flex-start; }
  .system-state { max-width: 13rem; }
  .week-layout, .split-layout { grid-template-columns: 1fr; }
  .week-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .readiness { grid-column: 1 / -1; }
  .standard-grid { grid-template-columns: 1fr; }
  .hub-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .owner-focus { grid-template-columns: 1fr; }
  .desk-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .topbar { min-height: 0; display: block; padding: 1rem; }
  .system-state { margin-top: .8rem; max-width: none; }
  .tabs { padding: 0 .4rem; }
  main { padding: 1.4rem .85rem 4rem; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .section-heading .primary { width: 100%; }
  .week-meta, .plan-grid, .range-grid, .week-side { grid-template-columns: 1fr; }
  .weekly-sheet { padding: 1rem; border-radius: 12px; }
  .readiness { grid-column: auto; }
  .board { margin-right: -.85rem; }
  .choice-row { display: grid; }
  .hub-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calendar-item { grid-template-columns: 1fr; }
  .owner-focus { padding: 1rem; border-radius: 12px; }
  .desk-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-row { display: grid; gap: .55rem; }
  .task-row .card-actions { margin-top: 0; }
  .task-row .card-actions button { width: 100%; }
  .production-work-list.board { margin-right: -.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
