:root {
  --bg: #f6f5f2; --card: #fff; --ink: #222; --sub: #666; --line: #ddd; --accent: #2a6df4; --ok: #1f8a4c; --warn: #b26a00; --ng: #c62828;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 12px; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--ng); }
button.link { border: none; background: none; color: var(--accent); padding: 4px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
label { display: block; margin: 8px 0; }
label > input, label > select { display: block; width: 100%; margin-top: 4px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.msg { color: var(--ng); min-height: 1.2em; }
.login { display: flex; justify-content: center; padding: 10vh 16px; }
.login form { width: 100%; max-width: 360px; }
.login h1 { font-size: 20px; margin: 0 0 8px; }
.login button { width: 100%; margin-top: 8px; padding: 10px; }

.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-size: 16px; }
.acct { font-size: 13px; color: var(--sub); }
.acct.ng { color: var(--ng); }
a.button { display: inline-block; text-decoration: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; color: var(--ink); background: #fff; }
a.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.grow { flex: 1; }
.who { font-size: 13px; color: var(--sub); }
.tabs { display: flex; gap: 4px; padding: 8px 16px 0; overflow-x: auto; }
.tabs button { border-radius: 8px 8px 0 0; border-bottom: none; white-space: nowrap; }
.tabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.bar { margin: 8px 16px 0; padding: 8px 12px; border-radius: 8px; background: #e8f0fe; }
.bar.ng { background: #fdecea; color: var(--ng); }
main { padding: 12px 16px 48px; max-width: 1100px; }
h2 { font-size: 17px; margin: 16px 0 8px; }
.note { color: var(--sub); font-size: 13px; }

/* 写真と動画 */
.drop { border: 2px dashed #aab; border-radius: var(--radius); padding: 24px 16px; text-align: center; background: #fff; }
.drop.over { border-color: var(--accent); background: #eef3ff; }
.drop p { margin: 4px 0; }
.drop .big { font-size: 17px; }
.queue { list-style: none; padding: 0; margin: 8px 0; }
.queue li { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-size: 13px; border-bottom: 1px solid #eee; }
.queue .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .ok { color: var(--ok); }
.queue .ng { color: var(--ng); }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0 8px; }
.filters button.on { background: #333; color: #fff; border-color: #333; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.08); display: flex; flex-direction: column; }
.tile .pic { aspect-ratio: 1 / 1; background: #eee; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tile .pic img { width: 100%; height: 100%; object-fit: contain; background: #222; }
.tile .pic .vid { font-size: 13px; color: var(--sub); text-align: center; padding: 8px; }
.tile .info { padding: 6px 8px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.tile .badges { display: flex; gap: 4px; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: #eee; }
.badge.used { background: #e0f2e9; color: var(--ok); }
.badge.plan { background: #fff3e0; color: var(--warn); }
.badge.warn { background: #fdecea; color: var(--ng); }
.tile select { font-size: 12px; padding: 3px 4px; }
.tile .acts { display: flex; gap: 4px; flex-wrap: wrap; }
.tile .acts button { font-size: 12px; padding: 3px 8px; }

/* 切り取り */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 16px; z-index: 10; }
.sheet { background: #fff; border-radius: var(--radius); padding: 16px; width: 100%; max-width: 960px; }
.sheet h2 { margin-top: 0; }
.ratios { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.ratios button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.stage { position: relative; margin: 8px auto; touch-action: none; user-select: none; overflow: hidden; background: #111; }
.stage canvas { display: block; }
.cbox { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); cursor: move; touch-action: none; }
.cbox::before, .cbox::after { content: ""; position: absolute; border: 1px dashed rgba(255,255,255,.5); }
.cbox::before { left: 33.3%; right: 33.3%; top: 0; bottom: 0; border-top: none; border-bottom: none; }
.cbox::after { top: 33.3%; bottom: 33.3%; left: 0; right: 0; border-left: none; border-right: none; }
/* 角のつまみ（枠の内側に置く＝写真のはしでも隠れない・指でつかめる大きさ） */
.handle { position: absolute; width: 34px; height: 34px; border: 0 solid #fff; touch-action: none; z-index: 1; filter: drop-shadow(0 0 2px rgba(0,0,0,.8)); }
.handle.nw { left: -2px; top: -2px; border-left-width: 6px; border-top-width: 6px; cursor: nwse-resize; }
.handle.ne { right: -2px; top: -2px; border-right-width: 6px; border-top-width: 6px; cursor: nesw-resize; }
.handle.sw { left: -2px; bottom: -2px; border-left-width: 6px; border-bottom-width: 6px; cursor: nesw-resize; }
.handle.se { right: -2px; bottom: -2px; border-right-width: 6px; border-bottom-width: 6px; cursor: nwse-resize; }
.sheet .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.sheet .size { color: var(--sub); font-size: 13px; text-align: center; }

/* 予定表 */
.day h2 { display: flex; gap: 8px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.post { display: flex; gap: 12px; background: #fff; border-radius: var(--radius); padding: 10px; margin: 8px 0; box-shadow: 0 1px 3px rgba(0,0,0,.08); border-left: 5px solid #bbb; }
.post.st-approved { border-left-color: var(--ok); }
.post.st-posted { border-left-color: #2a6df4; opacity: .85; }
.post.st-failed, .post.st-missed, .post.st-check { border-left-color: var(--ng); }
.post.st-skipped { opacity: .6; }
.ppic { width: 120px; min-width: 120px; height: 150px; padding: 0; overflow: hidden; background: #222; color: #fff; display: flex; align-items: center; justify-content: center; }
.ppic img { width: 100%; height: 100%; object-fit: contain; }
.pbody { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.phead { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pbody textarea { width: 100%; resize: vertical; }
.count { font-size: 12px; color: var(--sub); }
.count.ng { color: var(--ng); font-weight: bold; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.tag.on { background: #333; color: #fff; border-color: #333; }
.tag.add { color: var(--accent); }
.checks { margin: 0; padding-left: 18px; font-size: 13px; }
.checks:empty { display: none; }
.checks .ng { color: var(--ng); }
.checks .warn { color: var(--warn); }
.badge.s-approved { background: #e0f2e9; color: var(--ok); }
.badge.s-posted { background: #e8f0fe; color: var(--accent); }
.badge.s-failed, .badge.s-missed, .badge.s-check { background: #fdecea; color: var(--ng); }
.pick { display: flex; flex-direction: column; gap: 4px; padding: 4px; background: #fff; }
.pick img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; background: #222; }
textarea { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.slot { margin: 4px 0; }
@media (max-width: 600px) {
  .post { flex-direction: column; }
  .ppic { width: 100%; height: 220px; }
}

/* AI の案 */
.ai { display: flex; flex-direction: column; gap: 6px; }
.ai > button { align-self: flex-start; }
.sugg { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fafcff; }
.sugg.used { border-color: var(--ok); background: #f3fbf6; }
.sugg p { margin: 4px 0; }
.shead { display: flex; gap: 8px; align-items: baseline; }
.stext { white-space: pre-wrap; }
.warn { color: var(--warn); font-size: 13px; }

/* 数字 */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 8px 0; }
.kpi { background: #fff; border-radius: var(--radius); padding: 10px 12px; box-shadow: 0 1px 3px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 2px; }
.kpi strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
img.mini { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; display: block; }
tr.best td { background: #fffbe6; }
h3 { font-size: 14px; margin: 10px 0 4px; }
.card ul { margin: 4px 0; padding-left: 20px; }

/* 表 */
table { border-collapse: collapse; width: 100%; background: #fff; border-radius: var(--radius); overflow: hidden; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #eee; vertical-align: top; }
th { background: #fafafa; }
.pw { font-family: ui-monospace, Consolas, monospace; font-size: 18px; background: #fffbe6; padding: 8px 12px; border-radius: 8px; display: inline-block; margin: 4px 0; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.form-row label { margin: 0; }
@media (max-width: 600px) {
  main { padding: 8px 10px 48px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
