:root {
  --ink: #20231f;
  --muted: #74766f;
  --paper: #f3f0e8;
  --card: #fcfbf7;
  --line: #d8d4ca;
  --green: #315f49;
  --red: #b64538;
  --orange: #d16f36;
  --blue: #3c6176;
  --violet: #66506f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(49,95,73,.10), transparent 30rem),
    var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell { max-width: 1680px; margin: 0 auto; padding: 34px 34px 70px; }
.topbar { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 26px; }
.eyebrow { margin: 0 0 6px; color: var(--green); font: 700 12px/1.2 ui-monospace, monospace; letter-spacing: .16em; }
h1 { margin: 0; font-family: Georgia, "Yu Mincho", serif; font-size: clamp(28px, 4vw, 54px); font-weight: 500; letter-spacing: -.03em; }
.today { margin: 0; color: var(--muted); white-space: nowrap; }
.topbar-tools { display: flex; align-items: center; gap: 14px; }
.logout { color: var(--muted); font-size: 12px; text-decoration: none; border-bottom: 1px solid currentColor; }

.composer { background: var(--card); border: 1px solid var(--line); border-top: 5px solid var(--green); border-radius: 4px 4px 14px 14px; padding: 22px; box-shadow: 0 18px 50px rgba(32,35,31,.07); }
.composer > h2 { margin: 0 0 18px; font: 700 14px/1.2 ui-monospace, monospace; letter-spacing: .08em; }
#task-form { display: grid; grid-template-columns: minmax(220px,1.2fr) minmax(280px,1.7fr) minmax(190px,.9fr) 170px auto; gap: 14px; align-items: start; }
.field { display: grid; gap: 7px; }
.field label { font-size: 12px; font-weight: 700; color: #4d504a; }
.field label span { color: var(--red); }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); padding: 11px 12px; outline: none; }
textarea { min-height: 44px; max-height: 130px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(49,95,73,.12); }
.actions { display: flex; gap: 8px; padding-top: 25px; }
.actions button, .dialog-actions button { min-height: 44px; border: 1px solid transparent; border-radius: 8px; padding: 0 17px; font-weight: 700; white-space: nowrap; }
.primary { color: #fff; background: var(--green); }
.secondary { color: var(--ink); background: #fff; border-color: var(--line) !important; }
.danger { color: #fff; background: var(--red); }
.danger:disabled { background: #d5d2ca; cursor: not-allowed; }

.board { display: grid; grid-template-columns: repeat(4, minmax(250px,1fr)); gap: 12px; margin-top: 24px; }
.lane { min-height: 460px; background: rgba(252,251,247,.74); border: 1px solid var(--line); border-radius: 12px; padding: 15px; }
.lane-heading { display: flex; justify-content: space-between; gap: 8px; align-items: start; padding-bottom: 12px; border-bottom: 3px solid var(--ink); }
.lane-heading > div { display: flex; align-items: baseline; gap: 9px; }
.lane h2 { margin: 0; font-size: 18px; line-height: 1.35; }
.lane-mark { color: var(--muted); font: 700 11px/1 ui-monospace, monospace; }
.count { display: grid; place-items: center; min-width: 27px; height: 27px; border-radius: 50%; color: #fff; background: var(--ink); font: 700 12px/1 ui-monospace, monospace; }
.lane-note { margin: 9px 0 14px; color: var(--muted); font-size: 12px; }
.urgent .lane-heading { border-color: var(--orange); }
.digitalize .lane-heading { border-color: var(--green); }
.komatsu .lane-heading { border-color: var(--blue); }
.personal .lane-heading { border-color: var(--violet); }

.task-list { display: grid; gap: 8px; }
.task-row { display: grid; grid-template-columns: 18px 22px minmax(0, 1fr) auto; grid-template-areas: "drag check content edit"; align-items: start; gap: 7px; padding: 11px 10px; background: #fff; border: 1px solid #e2ded4; border-radius: 8px; transition: transform .15s, box-shadow .15s; }
.task-row:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(32,35,31,.08); }
.task-row.is-dragging { visibility: hidden; }
.dragging-task { user-select: none; }
.drag-ghost { position: fixed; z-index: 9999; margin: 0; pointer-events: none; opacity: .92; transform: scale(1); transform-origin: center; box-shadow: 0 8px 22px rgba(32,35,31,.18); transition: left .035s linear, top .035s linear, width .15s ease, transform .15s ease, box-shadow .15s ease, opacity .15s ease; will-change: left, top, transform; }
.drag-ghost.is-floating { opacity: .98; transform: scale(1.035) rotate(.35deg); box-shadow: 0 18px 38px rgba(32,35,31,.28); }
.drag-ghost.is-settling { opacity: .8; transform: scale(1); box-shadow: 0 5px 14px rgba(32,35,31,.13); transition-duration: .16s; }
.drag-handle { grid-area: drag; width: 18px; min-height: 28px; padding: 0; color: #777a74; background: #f0f1ee; border: 1px solid #d9dcd7; border-radius: 5px; font-size: 16px; line-height: 1; cursor: grab; touch-action: none; user-select: none; }
.drag-handle:active { cursor: grabbing; }
.task-check { grid-area: check; width: 18px; height: 18px; margin-top: 2px; accent-color: var(--green); }
.task-content { grid-area: content; display: grid; grid-template-columns: 1fr auto; gap: 5px 8px; width: 100%; min-width: 0; padding: 0; text-align: left; border: 0; color: inherit; background: none; }
.task-title { font-weight: 700; line-height: 1.45; word-break: break-word; }
.task-due { color: var(--muted); font: 700 11px/1.6 ui-monospace, monospace; white-space: nowrap; }
.task-due.overdue { color: var(--red); }
.task-memo { display: none; grid-column: 1 / -1; padding: 7px 0 2px; color: #62645f; font-size: 13px; line-height: 1.65; white-space: pre-wrap; border-top: 1px dashed var(--line); }
.task-content[aria-expanded="true"] .task-memo { display: block; }
.edit-task { grid-area: edit; align-self: center; min-height: 30px; padding: 0 9px; color: var(--green); background: #f5f7f4; border: 1px solid #d4ded7; border-radius: 6px; font-size: 12px; font-weight: 700; }
.task-row.is-editing { outline: 2px solid var(--green); outline-offset: 1px; }
.empty { padding: 28px 8px; color: #999b95; text-align: center; font-size: 13px; border: 1px dashed var(--line); border-radius: 8px; }

dialog { width: min(450px, calc(100% - 32px)); border: 0; border-radius: 14px; padding: 25px; box-shadow: 0 28px 100px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(25,27,24,.55); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 9px; font-family: Georgia, "Yu Mincho", serif; }
dialog p:not(.eyebrow) { color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.dialog-actions button:not(.danger) { border-color: var(--line); background: #fff; }

.sync-status { grid-column: 1 / -1; min-height: 1.4em; margin: 0; color: var(--muted); font-size: .82rem; }
.sync-status.error { color: var(--red); }

@media (max-width: 1100px) {
  #task-form { grid-template-columns: 1fr 1fr; }
  .memo-field { grid-column: span 2; }
  .actions { justify-content: flex-end; padding-top: 0; }
  .board { overflow-x: auto; grid-template-columns: repeat(4, minmax(280px, 1fr)); padding-bottom: 10px; scroll-snap-type: x proximity; }
  .lane { scroll-snap-align: start; }
}
@media (max-width: 650px) {
  .app-shell { padding: 22px 15px 50px; }
  .topbar { align-items: center; margin-bottom: 16px; }
  .topbar-tools { gap: 10px; }
  .today { font-size: 11px; }
  #task-form { display: grid; grid-template-columns: 1fr; }
  .memo-field { grid-column: auto; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; overflow: visible; margin-right: 0; padding-bottom: 0; scroll-snap-type: none; }
  .lane { min-height: 0; align-self: start; padding: 10px; }
  .lane-heading { padding-bottom: 9px; }
  .lane-heading > div { gap: 4px; }
  .lane h2 { font-size: 14px; }
  .lane-mark { display: none; }
  .count { min-width: 23px; height: 23px; font-size: 10px; }
  .lane-note { min-height: 2.8em; margin: 7px 0 10px; font-size: 10px; }
  .task-row { grid-template-columns: 18px 22px minmax(0, 1fr); grid-template-areas: "drag check blank" "content content content" "edit edit edit"; gap: 7px 6px; padding: 9px 8px; }
  .drag-handle { width: 15px; min-height: 25px; font-size: 15px; }
  .task-check { width: 16px; height: 16px; }
  .task-content { grid-template-columns: 1fr; gap: 2px; }
  .task-title { font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
  .task-due { font-size: 9px; }
  .task-memo { font-size: 11px; }
  .edit-task { justify-self: start; min-height: 27px; padding: 0 9px; font-size: 10px; }
  .empty { padding: 20px 4px; font-size: 11px; }
}
