:root {
  color-scheme: light;
  --ink: #16202e; --muted: #5d6b7c; --line: #dfe5ec; --bg: #f5f7fa; --card: #fff;
  --accent: #0b5ed7; --accent-ink: #fff; --danger: #c02626; --ok: #0f7a4f; --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.7;
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  background: var(--card); border-bottom: 1px solid var(--line); }
.top strong { margin-right: auto; font-size: 15px; }
.top a, .linkish { background: none; border: 0; padding: 0; color: var(--ink); font-size: 14px; text-decoration: none; cursor: pointer; }
.top a[aria-current="page"] { color: var(--accent); font-weight: 700; }
.linkish:hover, .top a:hover { color: var(--accent); }

.wrap { max-width: 860px; margin: 0 auto; padding: 28px 20px 96px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.head h1 { font-size: 22px; }

.btn { display: inline-block; padding: 10px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  font-weight: 600; font-size: 15px; text-decoration: none; color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { opacity: .9; color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.login { max-width: 400px; margin: 10vh auto 0; padding: 28px 24px; }
.login h1 { font-size: 20px; margin-bottom: 6px; }
.login .sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.login .btn { width: 100%; margin-top: 16px; }
.login .linkish { display: block; margin: 14px auto 0; color: var(--muted); }

label, .label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
input[type=email], input[type=text], input[type=date], input.code { width: 100%; padding: 10px 12px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; }
input.code { font-size: 24px; letter-spacing: .3em; text-align: center; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, .editor:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }

.msg { margin: 0 0 16px; padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.msg.err { background: #fdecec; color: var(--danger); }
.msg.ok { background: #e6f6ee; color: var(--ok); }

.section-title { margin: 28px 0 10px; font-size: 14px; font-weight: 700; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: inherit; text-decoration: none; }
a.row:hover { background: #f0f5fc; }
.row .t { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.row .d { color: var(--muted); font-size: 13px; white-space: nowrap; }
.tag { flex: none; padding: 1px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #e8effa; color: var(--accent); }
.tag.press { background: #ece8fb; color: #5436b8; }
.tag.draft { background: #fdf2dc; color: #8a5a00; }
.empty { padding: 20px 16px; color: var(--muted); font-size: 14px; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.field { margin-bottom: 16px; }
.seg { display: inline-flex; gap: 4px; padding: 4px; background: #eaeef3; border-radius: 10px; }
.seg label { margin: 0; padding: 6px 14px; border-radius: 7px; font-size: 14px; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg input:checked + span { color: var(--accent); }
.seg label:has(input:checked) { background: #fff; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); }

.cover { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cover img { width: 160px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.toolbar { position: sticky; top: 53px; z-index: 3; display: flex; flex-wrap: wrap; gap: 4px; padding: 8px;
  background: var(--card); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
.toolbar button { padding: 5px 12px; background: none; border: 0; border-radius: 7px; font-size: 14px; cursor: pointer; }
.toolbar button:hover { background: #eaf1fb; color: var(--accent); }
.editor { min-height: 340px; padding: 18px 20px; background: var(--card); border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius); overflow-wrap: anywhere; }
.editor:empty::before { content: "ここに本文を入力します"; color: var(--muted); }
.editor p { margin: 0 0 1em; }
.editor h2 { font-size: 22px; margin: 1.2em 0 .5em; }
.editor h3 { font-size: 18px; margin: 1em 0 .4em; }
.editor img { display: block; max-width: 100%; height: auto; margin: 1em 0; border-radius: 8px; }
.editor ul, .editor ol { padding-left: 1.5em; }

.actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 20px; background: var(--card); border-top: 1px solid var(--line); }
.actions .spacer { flex: 1; }

.preview { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--card); }
.preview header { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.preview iframe { flex: 1; width: 100%; border: 0; }

.add { display: flex; gap: 8px; padding: 16px; }
.add input { flex: 1; min-width: 0; }

@media (max-width: 600px) {
  .fields { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
  .row .t { flex-basis: 100%; order: 3; }
  .top { gap: 12px; padding: 12px 14px; }
  .top strong { font-size: 14px; }
  .actions { padding: 10px 12px; }
  .actions .btn { padding: 10px 12px; font-size: 14px; }
}
