:root {
  --bg: #ffffff;
  --soft: #f7f7f7;
  --ink: #111111;
  --muted: #737373;
  --faint: #a3a3a3;
  --line: #ebebeb;
  --line-strong: #d9d9d9;
  --green: #15803d;
  --blue: #2563eb;
  --amber: #d97706;
  --red: #dc2626;
  --gray: #a3a3a3;
  --radius: 8px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { background: var(--bg); }
body {
  margin: 0;
  color: var(--ink);
  font: 14px/1.5 "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- header */
.top {
  position: sticky; top: 0; z-index: 10; background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.top-in { max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 28px; }
.logo { font-weight: 600; letter-spacing: -.02em; font-size: 15px; text-decoration: none; }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 6px; }
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--ink); background: var(--soft); }
.spacer { flex: 1; }
.me { color: var(--muted); display: flex; align-items: center; gap: 14px; }
.me form { margin: 0; }
.link { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; white-space: nowrap; }
.link:hover { color: var(--ink); }

main { max-width: 1200px; margin: 0 auto; padding: 28px 24px 80px; }

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--bg); cursor: pointer;
  font-weight: 500; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #333; }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { background: var(--soft); }
.btn.icon { width: 34px; padding: 0; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.lg { height: 42px; padding: 0 20px; }
.btn.wide { width: 100%; }

input[type=text], input[type=password], input[type=number], input[type=time], input[type=datetime-local], textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 8px 10px; background: var(--bg);
}
textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
input:focus, textarea:focus { outline: none; border-color: var(--ink); }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 2px; gap: 2px; }
.seg button { border: 0; background: none; height: 28px; padding: 0 12px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--soft); color: var(--ink); }

.label { display: block; font-weight: 500; margin: 0 0 6px; }
.hint { color: var(--muted); font-weight: 400; }
.field { margin-bottom: 22px; }

.msg { padding: 10px 12px; border-radius: var(--radius); margin-bottom: 16px; }
.msg.err { background: #fef2f2; color: var(--red); }
.msg.ok { background: #f0fdf4; color: var(--green); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; background: var(--gray); }
.dot.green { background: var(--green); }
.dot.blue { background: var(--blue); }
.dot.amber { background: var(--amber); }
.dot.red { background: var(--red); }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }

/* ---------------------------------------------------------------- calendar */
.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.cal-head h1 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; margin: 0 8px 0 0; }
.cal-head .range { color: var(--muted); }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--faint); font-size: 12px; }
.live .dot { background: var(--line-strong); }
.live.on .dot { background: var(--green); }

.attention { border: 1px solid #fecaca; background: #fffafa; border-radius: var(--radius); margin-bottom: 20px; }
.attention h3 { margin: 0; padding: 10px 14px; font-size: 13px; font-weight: 600; color: var(--red); border-bottom: 1px solid #fde2e2; }
.attention .row { border-bottom: 1px solid #fde2e2; }
.attention .row:last-child { border-bottom: 0; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.day { border-right: 1px solid var(--line); min-height: 420px; display: flex; flex-direction: column; }
.day:last-child { border-right: 0; }
.day-h { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: 6px; }
.day-h b { font-weight: 600; font-size: 13px; }
.day-h span { color: var(--muted); font-size: 13px; }
.day.today .day-h b { color: var(--ink); }
.day.today .day-h span { background: var(--ink); color: #fff; border-radius: 10px; padding: 0 7px; }
.day.past { background: #fcfcfc; }
.day-b { padding: 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.day.drop-over { background: #f5f8ff; }

.item {
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; background: var(--bg); cursor: pointer; text-align: left;
  display: block; width: 100%;
}
.item:hover { border-color: var(--line-strong); }
.item .t { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; }
.item .t b { font-weight: 600; font-variant-numeric: tabular-nums; }
.item .c { margin-top: 3px; font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.item.dim { opacity: .55; }
.item[draggable=true] { cursor: grab; }
.item.dragging { opacity: .35; }
.free {
  border: 1px dashed var(--line-strong); border-radius: 6px; padding: 6px 9px; font-size: 12px; color: var(--faint);
  background: none; cursor: pointer; text-align: left; display: flex; justify-content: space-between; font-variant-numeric: tabular-nums;
}
.free:hover { color: var(--ink); border-color: var(--faint); }
.free.drop-over { border-color: var(--blue); color: var(--blue); background: #f5f8ff; }

/* list view */
.list { border: 1px solid var(--line); border-radius: var(--radius); }
.list-day { padding: 18px 16px 6px; font-weight: 600; font-size: 13px; }
.list-day span { color: var(--muted); font-weight: 400; margin-left: 6px; }
.row { display: grid; grid-template-columns: 56px 40px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px 16px; cursor: pointer; }
.row:hover { background: var(--soft); }
.row .time { font-variant-numeric: tabular-nums; font-weight: 500; }
.row .thumb { width: 40px; height: 64px; border-radius: 4px; background: var(--soft); object-fit: cover; }
.row .text { min-width: 0; }
.row .text div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .text small { color: var(--muted); }
.list-sep { padding: 16px; border-top: 1px solid var(--line); }
.empty { color: var(--muted); padding: 48px 16px; text-align: center; }

/* ---------------------------------------------------------------- drawer */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .18); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 100%; background: var(--bg); z-index: 21;
  border-left: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column;
}
.drawer-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 12px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 1; }
.drawer-b { padding: 20px; }
.drawer video { width: 100%; max-height: 56vh; background: #000; border-radius: var(--radius); display: block; margin-bottom: 18px; }
.gone { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 28px 16px; text-align: center; color: var(--muted); margin-bottom: 18px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; margin-bottom: 22px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }
.section { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.section h4 { margin: 0 0 12px; font-size: 13px; font-weight: 600; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline input { flex: 1; min-width: 180px; }
.history { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.history li { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 5px 0; color: var(--muted); }
.history li b { color: var(--ink); font-weight: 500; }
.warn { color: var(--red); }

/* ---------------------------------------------------------------- upload + settings */
.narrow { max-width: 560px; margin: 0 auto; }
.page-h { margin: 8px 0 28px; }
.page-h h1 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 4px; }
.page-h p { margin: 0; color: var(--muted); }

.picker {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 36px 16px; cursor: pointer; color: var(--muted);
}
.picker:hover, .picker.over { border-color: var(--ink); color: var(--ink); }
.picker b { color: var(--ink); font-weight: 500; }
.picker input { display: none; }
.chosen { display: flex; gap: 16px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.chosen video { width: 64px; height: 114px; object-fit: cover; border-radius: 4px; background: #000; flex: none; }
.chosen .meta { min-width: 0; flex: 1; }
.chosen .meta div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.chosen .meta small { color: var(--muted); }

.when { display: grid; gap: 8px; }
.opt { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; }
.opt:hover { border-color: var(--line-strong); }
.opt input[type=radio] { margin: 3px 0 0; accent-color: var(--ink); }
.opt.on { border-color: var(--ink); }
.opt b { font-weight: 500; display: block; }
.opt small { color: var(--muted); }
.opt input[type=datetime-local] { margin-top: 8px; }
.counter { text-align: right; color: var(--faint); font-size: 12px; margin-top: 4px; }

.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 16px; }
.progress i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .2s; }
.prog-text { color: var(--muted); margin-top: 8px; font-size: 13px; }

.slots { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 24px; }
.slot-row { display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.slot-row:last-child { border-bottom: 0; }
.slot-row b { font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 2px 4px 2px 9px; font-variant-numeric: tabular-nums; }
.chip button { border: 0; background: none; color: var(--faint); cursor: pointer; padding: 0 4px; font-size: 15px; line-height: 1; }
.chip button:hover { color: var(--red); }
.chips input[type=time] { width: auto; padding: 3px 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------------------------------------------------------------- login */
.login { max-width: 340px; margin: 18vh auto 0; padding: 0 16px; }
.login h1 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 28px; }
.login .field { margin-bottom: 14px; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 860px) {
  .top-in { padding: 0 16px; gap: 16px; }
  .me span { display: none; }
  main { padding: 20px 16px 64px; }
  .week { grid-template-columns: 1fr; }
  .day { border-right: 0; border-bottom: 1px solid var(--line); min-height: 0; }
  .day:last-child { border-bottom: 0; }
  .day-b:empty { display: none; }
  .row { grid-template-columns: 48px 36px minmax(0, 1fr); }
  .row .status { grid-column: 3; }
  .row .thumb { width: 36px; height: 58px; grid-row: span 2; }
  .two { grid-template-columns: 1fr; }
  .slot-row { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 520px) {
  .nav a { padding: 6px 6px; }
  .new-label { display: none; }
}
