:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --ink: #161616;
  --muted: #5f5f5f;
  --line: #e4e4e0;
  --accent: #111111;
  --accent-ink: #f7f7f5;
  --danger: #9d2c2c;
  --lane: 210px;
  --header-h: 56px;
  --font: "Helvetica Neue", "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #111111;
  --surface: #1b1b1b;
  --ink: #f3f3f1;
  --muted: #a8a8a8;
  --line: #2e2e2e;
  --accent: #f3f3f1;
  --accent-ink: #111111;
  --danger: #ff8d8d;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px 8px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  margin-right: auto;
}

.logo {
  height: 36px;
  width: auto;
  display: block;
}

.logo-on-dark { display: none; }
html[data-theme="dark"] .logo-on-light { display: none; }
html[data-theme="dark"] .logo-on-dark { display: block; }

.studio {
  font-size: 13px;
  letter-spacing: 0.16em;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.updated, .sync-label, #sessionUser { margin: 0; color: var(--muted); font-size: 13px; }
.needs-edit:disabled { opacity: 0.4; cursor: default; }

.top-actions, .toolbar-actions, .dialog-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.seg {
  display: flex;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 2px;
}

.seg button, .btn {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 999px;
  padding: 7px 12px;
}

.seg button.is-on {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn { border-color: var(--line); background: var(--surface); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }

.banner {
  margin: 8px 24px 0;
  padding: 10px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.banner p { margin: 0; flex: 1; font-size: 13px; color: var(--muted); }
.banner.is-hidden { display: none; }

.status-line {
  min-height: 1.4em;
  margin: 8px 24px 0;
  font-size: 13px;
  color: var(--muted);
}
.status-line.is-error { color: var(--danger); }

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  padding: 12px 24px 4px;
}
.filter-bar { display: flex; flex-direction: column; gap: 8px; }
.filter-group { display: flex; align-items: flex-start; gap: 10px; }
.filter-label {
  flex: 0 0 auto;
  min-width: 3.2em;
  padding-top: 7px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}
.status-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 3px;
}
.status-seg button {
  border: 0;
  background: transparent;
  border-radius: 7px;
  padding: 6px 11px;
  color: var(--muted);
}
.status-seg button.is-on { background: var(--accent); color: var(--accent-ink); }
body[data-screen="home"] .only-project { display: none; }

.search input, dialog input, dialog select, dialog textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 10px;
}
.search input { min-width: 180px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
}
.chips.people .chip.is-on {
  background: color-mix(in srgb, var(--person, var(--ink)) 18%, var(--surface));
  color: var(--ink);
  border-color: var(--person, var(--ink));
}
.chips.kinds .chip {
  border-radius: 6px;
  border-left-width: 4px;
  border-left-color: var(--kind, var(--line));
}
.chips.kinds .chip.is-on {
  background: color-mix(in srgb, var(--kind, var(--ink)) 16%, var(--surface));
  color: var(--ink);
  border-color: var(--kind, var(--ink));
}
.toolbar-actions {
  justify-content: space-between;
  margin-left: 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.manage { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.manage .filter-label { flex: none; padding-top: 0; }
.btn.quiet { background: transparent; }
#memberRoster, #genreRoster { width: min(680px, calc(100vw - 32px)); }
.roster-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
  max-height: 52vh;
  overflow: auto;
}
.roster-row {
  display: grid;
  grid-template-columns: 44px 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}
#genreRoster .roster-row { grid-template-columns: 44px 1fr auto; }
.roster-row input[type="color"] { width: 44px; height: 36px; padding: 2px; }
.swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

#main { padding: 0 24px 32px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.card {
  display: block;
  text-align: left;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}
.card strong { display: block; font-size: 18px; margin-bottom: 8px; }
.card span { color: var(--muted); font-size: 13px; }

.gantt-scroll {
  overflow: auto;
  max-height: calc(100vh - 220px);
  min-height: 280px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.gantt-canvas { position: relative; min-width: 100%; --lane-w: var(--lane); }
.jump {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 12px;
}
.gantt-header, .row { display: flex; align-items: stretch; }
.gantt-header {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  height: var(--header-h);
}
.lane {
  position: sticky;
  left: 0;
  width: var(--lane);
  flex: 0 0 var(--lane);
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 3;
  padding: 8px 12px;
}
.gantt-header .lane {
  z-index: 5;
  display: flex;
  align-items: flex-end;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.lane-btn {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0;
}
.lane-btn strong, .milestone-row .lane strong { display: block; font-size: 15px; }
.lane-btn span, .milestone-row .lane span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.time-head { position: relative; height: var(--header-h); flex: 0 0 auto; }
.month-label, .tick-label {
  position: absolute;
  top: 0;
  height: 26px;
  display: flex;
  align-items: center;
  padding-left: 8px;
  font-size: 12px;
  color: var(--muted);
  border-left: 1px solid var(--line);
  overflow: hidden;
  white-space: nowrap;
}
.tick-label { top: 26px; height: 30px; font-variant-numeric: tabular-nums; }
.row { border-bottom: 1px solid var(--line); }
.row.is-drop { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.track { cursor: cell; }
.track { position: relative; height: 100%; }
.weekend, .today-line { position: absolute; top: 0; bottom: 0; pointer-events: none; }
.weekend { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.today-line, .today-mark { width: 2px; background: var(--ink); z-index: 2; }
.today-mark { position: absolute; top: 0; height: 100%; }
.today-mark span {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.milestone-row .track { overflow: visible; }
.milestone-line {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dashed var(--muted);
  z-index: 2;
  pointer-events: none;
}
.ms-mark {
  position: absolute;
  top: 8px;
  height: 24px;
  border: 0;
  background: transparent;
  padding: 2px 0 0 16px;
  cursor: grab;
  z-index: 3;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}
.ms-mark::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 11px;
  height: 11px;
  background: var(--ink);
  transform: rotate(45deg);
}
.bar {
  position: absolute;
  height: 28px;
  border: 0;
  border-radius: 7px;
  padding: 0 8px;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: grab;
  z-index: 1;
}
.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--bar, var(--ink));
  pointer-events: none;
}
.bar-label {
  position: relative;
  z-index: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  text-shadow: 0 0 3px var(--surface), 0 0 3px var(--surface);
}
.bar.is-done { opacity: 0.72; }
.bar.is-blocked { outline: 1px dashed var(--danger); outline-offset: -3px; }
.bar.is-milestone {
  width: 14px !important;
  height: 14px;
  padding: 0;
  border-radius: 2px;
  transform: translate(8px, 8px) rotate(45deg);
  overflow: visible;
  background: var(--bar, var(--ink)) !important;
}
.bar.is-milestone .bar-label {
  position: absolute;
  left: 16px;
  top: -4px;
  transform: rotate(-45deg);
  text-shadow: none;
}
.handle { position: absolute; top: 0; bottom: 0; width: 8px; z-index: 2; cursor: ew-resize; }
.handle.w { left: 0; }
.handle.e { right: 0; }

.list {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
}
.list th, .list td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.list th { font-size: 12px; color: var(--muted); font-weight: 500; }
.list button.linkish { border: 0; background: transparent; padding: 0; font-weight: 700; }
.list input[type="range"] { width: 120px; }
.ms-list { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.ms-list button {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 650;
}
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

dialog {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
#helpDialog { width: min(680px, calc(100vw - 32px)); }
dialog form, .help { padding: 18px; }
.dialog-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; font-size: 22px; }
.icon-btn { margin-left: auto; border: 0; background: transparent; font-size: 22px; line-height: 1; }
dialog label, fieldset { display: block; margin: 10px 0; font-size: 13px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.check input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 12px; }
legend { padding: 0 6px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.55; }
.help h3 { margin: 16px 0 6px; font-size: 15px; }
.help ul, .help ol { margin: 0; padding-left: 1.2em; }
.spacer { flex: 1; }
.file-btn input { display: none; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.92em; }

@media (max-width: 800px) {
  .toolbar-actions { margin-left: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  :root { --lane: 148px; }
}
