/* ニッコーノート
   色はシフト管理アプリ（aishift）と同じ緑系。いいね・新着だけ暖色。記事の見出しと本文は UD明朝。
   スマホ優先。パソコンでは中央の1列に収める。 */
:root {
  --bg: #f2f5f0;
  --surface: #ffffff;
  --surface-2: #e9eee7;
  --ink: #1c241f;
  --muted: #5c685f;
  --border: #dce3da;
  --accent: #1e7a4f;
  --accent-ink: #ffffff;
  --accent-soft: #e0efe6;
  --warm: #c0503c;
  --warm-ink: #ffffff;
  --danger: #b0503c;
  --warn: #7d5a12;
  --warn-soft: #f5ecd8;
  --scrim: rgba(20, 28, 23, .45);
  --shadow: rgba(28, 36, 31, .18);
  --ph-empty: #dfe6dc;
  --font-ui: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "BIZ UDPGothic", "Yu Gothic Medium", Meiryo, sans-serif;
  --font-read: "BIZ UDPMincho", "Hiragino Mincho ProN", "Yu Mincho", YuMincho, "Noto Serif JP", serif;
  --maxw: 42rem;
  --gutter: max(14px, calc((100% - var(--maxw)) / 2 + 14px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1411;
    --surface: #171d18;
    --surface-2: #1f271f;
    --ink: #e6ece7;
    --muted: #98a49b;
    --border: #2a332c;
    --accent: #4cc98b;
    --accent-ink: #0c2417;
    --accent-soft: #17331f;
    --warm: #e08a76;
    --warm-ink: #1d0f0b;
    --danger: #e08a76;
    --warn: #e0a44a;
    --warn-soft: #3a2d17;
    --scrim: rgba(0, 0, 0, .62);
    --shadow: rgba(0, 0, 0, .55);
    --ph-empty: #253026;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.7;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, figure { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; }

/* ---------- 共通の部品 ---------- */
.mark {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-read); font-weight: 700; font-size: 17px; line-height: 1;
}
.mark-lg { width: 60px; height: 60px; border-radius: 17px; font-size: 32px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 10px 16px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--ink);
  font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn-block { width: 100%; }
.btn-small {
  flex: none; display: inline-flex; align-items: center; min-height: 34px; padding: 4px 12px;
  border-radius: 9px; background: var(--accent); color: var(--accent-ink);
  font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.btn-text-danger {
  align-self: center; min-height: 44px; padding: 8px 12px; border: 0; background: none;
  color: var(--danger); font-size: 14px; text-decoration: underline; cursor: pointer;
}
.icon-btn {
  flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none;
}
.icon-btn svg { width: 22px; height: 22px; }
.text-link { align-self: center; font-size: 14px; padding: 8px; }
.notice {
  padding: 10px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--ink);
  font-size: 14px; line-height: 1.6;
}
.form-error { font-size: 14px; color: var(--danger); line-height: 1.5; }
.field-label, legend { font-size: 13px; font-weight: 700; color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.text-in, .text-area, .when-in {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 11px;
  background: var(--bg); color: var(--ink); font-size: 16px;
}

/* ---------- 起動中 ---------- */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); font-size: 14px; }

/* ---------- 画面の枠 ---------- */
.view { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body.has-tabbar .view { padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px)); }
.page { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 12px 12px calc(28px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; }
.appbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: env(safe-area-inset-top, 0px) var(--gutter) 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.appbar-title { flex: 1; min-width: 0; font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- ログイン ---------- */
.view-login { background: var(--surface); }
.login {
  width: 100%; max-width: 26rem; margin: 0 auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: calc(48px + env(safe-area-inset-top, 0px)) 22px calc(32px + env(safe-area-inset-bottom, 0px));
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 18px; text-align: center; }
.brand-name { font-family: var(--font-read); font-weight: 700; font-size: 24px; letter-spacing: .06em; }
.brand-sub { font-size: 13px; color: var(--muted); }
.code-input {
  width: 100%; padding: 10px; font-size: 28px; letter-spacing: .22em; text-align: center;
  font-variant-numeric: tabular-nums; border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--bg); color: var(--ink);
}
.login-note { font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- 一覧 ---------- */
.chips {
  display: flex; gap: 8px; padding: 10px var(--gutter); overflow-x: auto;
  background: var(--surface); border-bottom: 1px solid var(--border); scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 34px; padding: 4px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: 13.5px; white-space: nowrap; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.feed { display: flex; flex-direction: column; gap: 10px; }
.empty { padding: 40px 12px; text-align: center; color: var(--muted); font-size: 14px; }
.card {
  display: flex; flex-direction: column; gap: 10px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  color: inherit; text-decoration: none;
}
.card:hover { border-color: var(--accent); }
.card-row { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: start; }
.card-row.has-thumb { grid-template-columns: 1fr 76px; }
.card-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-cat { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--accent); }
.badge-new { font-size: 11px; line-height: 1.6; padding: 0 6px; border-radius: 4px; border: 1px solid var(--warm); color: var(--warm); }
.card-title { font-family: var(--font-read); font-weight: 700; font-size: 18px; line-height: 1.5; overflow-wrap: anywhere; }
.card-featured .card-title { font-size: 20px; }
.card-ex {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 13.5px; line-height: 1.7; color: var(--muted);
}
.card-meta { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card-likes { display: inline-flex; align-items: center; gap: 4px; color: var(--warm); }
.card-likes svg { width: 15px; height: 15px; }
.card-likes.on svg path { fill: currentColor; }

/* 写真（読み込むまでは色の四角） */
.ph { display: block; width: 100%; height: auto; border-radius: 10px; background: var(--ph-empty); object-fit: cover; }
.card-hero { aspect-ratio: 16 / 9; }
.card-thumb { width: 76px; height: 76px; aspect-ratio: 1; }
.ph.failed { min-height: 60px; }

.a2hs {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px dashed var(--accent); border-radius: 12px; background: var(--accent-soft); font-size: 13.5px;
}
.a2hs p { flex: 1; min-width: 0; line-height: 1.55; }
.a2hs .btn { min-height: 36px; padding: 4px 12px; font-size: 13px; }
.a2hs .icon-btn { width: 34px; height: 34px; }

/* ---------- 記事 ---------- */
.size-toggle { flex: none; display: flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.size-toggle button { min-width: 38px; min-height: 36px; padding: 2px 8px; border: 0; background: var(--surface); font-size: 13px; cursor: pointer; }
.size-toggle button + button { border-left: 1px solid var(--border); }
.size-toggle button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.reader {
  --read-size: 17px;
  width: 100%; max-width: var(--maxw); margin: 0 auto; flex: 1;
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px 18px calc(36px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
}
.reader[data-size="s"] { --read-size: 15px; }
.reader[data-size="l"] { --read-size: 20px; }
.rd-hero:empty { display: none; }
.rd-title { font-family: var(--font-read); font-weight: 700; font-size: calc(var(--read-size) + 6px); line-height: 1.5; overflow-wrap: anywhere; }
.rd-meta { font-size: 13px; color: var(--muted); }
.rd-aud { align-self: flex-start; font-size: 12.5px; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.rd-body { display: flex; flex-direction: column; gap: 1em; font-family: var(--font-read); font-size: var(--read-size); line-height: 2; overflow-wrap: anywhere; }
.rd-photos { display: flex; flex-direction: column; gap: 12px; }
.rd-photos:empty { display: none; }
.like-area { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 10px; padding-top: 20px; border-top: 1px solid var(--border); }
.like-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 8px 26px; border-radius: 999px;
  border: 1.5px solid var(--warm); background: var(--surface); color: var(--warm);
  font-weight: 700; font-size: 16px; cursor: pointer; font-variant-numeric: tabular-nums;
  transition: background-color .2s, color .2s;
}
.like-btn svg { width: 20px; height: 20px; }
.like-btn[aria-pressed="true"] { background: var(--warm); color: var(--warm-ink); }
.like-btn[aria-pressed="true"] svg path { fill: currentColor; }
.like-note, .like-only { font-size: 12.5px; color: var(--muted); text-align: center; }
.like-only { margin-top: 10px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---------- 書く ---------- */
.save-state { flex: none; max-width: 45%; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor {
  width: 100%; max-width: var(--maxw); margin: 0 auto; flex: 1;
  display: flex; flex-direction: column; gap: 18px;
  padding: 14px 14px calc(30px + env(safe-area-inset-bottom, 0px)); background: var(--surface);
}
.editor fieldset { margin: 0; padding: 0; border: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.editor legend { padding: 0; margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.seg label { position: relative; display: grid; place-items: center; min-height: 46px; padding: 6px 4px; text-align: center; font-size: 13px; line-height: 1.35; cursor: pointer; border-left: 1px solid var(--border); }
.seg label:first-child { border-left: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.text-title { font-family: var(--font-read); font-weight: 700; font-size: 18px; }
.text-area { min-height: 14em; resize: vertical; font-family: var(--font-read); font-size: 16px; line-height: 1.9; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb-wrap { position: relative; width: 76px; height: 76px; }
.thumb { width: 76px; height: 76px; aspect-ratio: 1; }
.thumb-busy { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 10px; background: var(--ph-empty); color: var(--muted); font-size: 11.5px; text-align: center; line-height: 1.4; }
.thumb-del {
  position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--surface); background: var(--ink); color: var(--surface); font-size: 15px; line-height: 1; cursor: pointer;
}
.thumb-add {
  width: 76px; height: 76px; border-radius: 10px; border: 1.5px dashed var(--border);
  background: var(--bg); color: var(--muted); font-size: 13px; line-height: 1.4; cursor: pointer;
}
.radio { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 15px; cursor: pointer; }
.radio input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.radio small { font-size: 12px; color: var(--muted); }
.store-chips { display: flex; flex-wrap: wrap; gap: 8px; padding-left: 30px; }
.store-chip { position: relative; }
.store-chip input { position: absolute; opacity: 0; pointer-events: none; }
.store-chip span { display: inline-flex; align-items: center; min-height: 36px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border); font-size: 13.5px; cursor: pointer; }
.store-chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.store-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.when-in { margin-left: 30px; width: auto; max-width: calc(100% - 30px); }
.editor-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---------- 書いた記事 ---------- */
.list-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); }
.mylist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; color: inherit; text-decoration: none; }
.row:hover { border-color: var(--accent); }
.row-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.state { font-size: 11.5px; font-weight: 700; padding: 1px 9px; border-radius: 999px; }
.state-published { background: var(--accent-soft); color: var(--accent); }
.state-scheduled { background: var(--warn-soft); color: var(--warn); }
.state-draft { background: var(--surface-2); color: var(--muted); }
.aud { font-size: 11.5px; color: var(--muted); padding: 0 9px; border: 1px solid var(--border); border-radius: 999px; }
.row-title { font-family: var(--font-read); font-weight: 700; font-size: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.row-meta { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--border); font-variant-numeric: tabular-nums; }
.stat { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.stat b { font-size: 20px; line-height: 1.25; color: var(--ink); }
.stat b small { margin-left: 2px; font-size: 12px; font-weight: 400; color: var(--muted); }
.stat-like b { color: var(--warm); }
.list-note { font-size: 12.5px; color: var(--muted); line-height: 1.7; }

/* ---------- 下のタブ（書く人） ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 0 var(--gutter) env(safe-area-inset-bottom, 0px);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; color: var(--muted); font-size: 12px; text-decoration: none; }
.tabbar svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--accent); font-weight: 700; }

/* ---------- シート・トースト ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: var(--scrim); }
.sheet {
  width: 100%; max-width: var(--maxw); max-height: 88vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom, 0px));
  border-radius: 18px 18px 0 0; background: var(--surface);
}
.sheet-title { font-size: 18px; font-weight: 700; line-height: 1.5; text-align: center; }
.sheet-body { display: flex; flex-direction: column; gap: 10px; }
.sheet-text { font-size: 14.5px; color: var(--muted); text-align: center; line-height: 1.7; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.sheet-actions.one { grid-template-columns: 1fr; }
.sheet .steps { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 8px; font-size: 15px; line-height: 1.6; }
.menu { display: flex; flex-direction: column; }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; border-bottom: 1px solid var(--border); font-size: 15px; }
.menu-item { min-height: 54px; padding: 0; border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; font-size: 15px; cursor: pointer; }
.menu-item.danger { color: var(--danger); }
.pw-form { display: flex; flex-direction: column; gap: 8px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 12px; background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 700; text-align: center; box-shadow: 0 12px 24px -12px var(--shadow);
}
body.has-tabbar .toast { bottom: calc(82px + env(safe-area-inset-bottom, 0px)); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
