/* おし簿 — ノート風デザイン
   色はすべて :root の変数。推しカラーを選ぶと app.js が上書きする */
:root {
  --bg: #fdeff4;        /* 机（背景） */
  --paper: #fffcfd;     /* ノートの紙 */
  --main: #ffa8c9;      /* 推しカラー */
  --deep: #e85f92;      /* 濃い推しカラー（ボタン・見出し） */
  --soft: #ffe3ee;      /* うすい推しカラー（チップ・帯） */
  --line: #f6d7e3;      /* 罫線 */
  --text: #614c56;
  --muted: #8d7781;
  --on-deep: #ffffff;
  --danger: #c84a5a;
  --radius: 14px;
  --shadow: 0 2px 0 rgba(97, 76, 86, .06), 0 6px 18px rgba(97, 76, 86, .08);
  --rule: 32px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(var(--line) 1.2px, transparent 1.3px);
  background-size: 18px 18px;
  line-height: 1.7;
  font-size: 16px;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.app { max-width: 1040px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }

/* ---------- ヘッダー ---------- */
.app-header { text-align: center; padding: 8px 0 4px; }
.logo { margin: 0; font-size: 1.6rem; letter-spacing: .08em; }
.logo-sub { margin: 4px 0 0; font-size: .82rem; color: var(--muted); }
.tape {
  display: inline-block;
  padding: 2px 18px;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.35) 0 6px, transparent 6px 12px),
    color-mix(in srgb, var(--main) 75%, transparent);
  transform: rotate(-2deg);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

/* ---------- タブ（スマホ：下に固定 / PC：ノートのインデックス） ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--paper);
  border-top: 2px dashed var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(97,76,86,.08);
}
.tab {
  border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 0;
  font-size: .78rem; font-weight: 500; padding: 4px 0; border-radius: 10px;
  color: var(--muted);
}
.tab-ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 2px; }
.tab { font-size: .72rem; white-space: nowrap; }
.tab.is-active { color: var(--deep); background: var(--soft); font-weight: 700; }

@media (min-width: 760px) {
  .app { padding-bottom: 32px; }
  .tabs {
    position: static; display: flex; gap: 6px; justify-content: flex-start;
    background: transparent; border: 0; box-shadow: none;
    padding: 12px 0 0 56px;
  }
  .tab {
    flex-direction: row; gap: 6px; font-size: .95rem;
    padding: 8px 18px 6px; border-radius: 12px 12px 0 0;
    background: color-mix(in srgb, var(--main) 35%, var(--paper));
    color: var(--text); transform: translateY(4px);
  }
  .tab.is-active { background: var(--main); color: var(--text); transform: translateY(0); }
  .tab-ico { width: 18px; height: 18px; margin: 0; }
}

/* ---------- ノート本体 ---------- */
.notebook {
  position: relative;
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, transparent 35px, color-mix(in srgb, var(--main) 55%, transparent) 35px, color-mix(in srgb, var(--main) 55%, transparent) 37px, transparent 37px),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--rule) - 1px), var(--line) calc(var(--rule) - 1px), var(--line) var(--rule));
  background-position: 0 0, 0 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 12px 28px 46px;
  min-height: 60vh;
}
/* リングの穴 */
.notebook::before {
  content: ""; position: absolute; left: 8px; top: 18px; bottom: 18px; width: 16px;
  background-image: radial-gradient(circle at 8px 8px, var(--bg) 0 6px, color-mix(in srgb, var(--text) 18%, transparent) 6px 7px, transparent 7.5px);
  background-size: 16px 44px; background-repeat: repeat-y;
}
@media (min-width: 760px) {
  .notebook { padding: 28px 32px 36px 72px; }
  .notebook { background-image:
      linear-gradient(to right, transparent 55px, color-mix(in srgb, var(--main) 55%, transparent) 55px, color-mix(in srgb, var(--main) 55%, transparent) 57px, transparent 57px),
      repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--rule) - 1px), var(--line) calc(var(--rule) - 1px), var(--line) var(--rule)); }
  .notebook::before { left: 18px; width: 20px; background-size: 20px 48px;
    background-image: radial-gradient(circle at 10px 10px, var(--bg) 0 7px, color-mix(in srgb, var(--text) 18%, transparent) 7px 8px, transparent 8.5px); }
}

.view { display: none; }
.view.is-active { display: block; }

.page-title {
  margin: 0 0 14px; font-size: 1.3rem; display: inline-block;
  background: linear-gradient(transparent 60%, color-mix(in srgb, var(--main) 55%, transparent) 60%);
  padding: 0 4px;
}
.sub-title { margin: 0 0 6px; font-size: 1.05rem; color: var(--deep); }
.hint { margin: 0 0 10px; font-size: .85rem; color: var(--muted); }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 2px solid var(--deep); background: var(--paper); color: var(--deep);
  border-radius: 999px; padding: 8px 18px; font-weight: 700; cursor: pointer;
  min-height: 44px; text-decoration: none;
}
.btn-main { background: var(--deep); color: var(--on-deep); box-shadow: 0 3px 0 color-mix(in srgb, var(--deep) 60%, #000); }
.btn-main:active { transform: translateY(2px); box-shadow: 0 1px 0 color-mix(in srgb, var(--deep) 60%, #000); }
.btn-sub { border-style: dashed; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn:focus-visible, .tab:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--deep) 45%, transparent); outline-offset: 2px;
}

/* ---------- フォーム ---------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 10px 16px; }
@media (min-width: 600px) { .grid { grid-template-columns: 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: 2px; margin: 0; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend, .f-field > span { font-size: .85rem; font-weight: 700; }
.field em { font-style: normal; font-size: .7rem; color: var(--on-deep); background: var(--deep); border-radius: 999px; padding: 0 6px; margin-left: 4px; }
input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]), select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px;
  background: rgba(255,255,255,.85); border: 2px solid var(--line); border-radius: 10px;
}
input:focus, select:focus, textarea:focus { border-color: var(--main); }
textarea { resize: vertical; }
select:disabled { color: var(--muted); background: rgba(255,255,255,.5); }
.is-invalid { border-color: var(--danger) !important; background: #fff4f5 !important; }

.total-line { text-align: right; margin: 8px 0; }
.total-line strong { font-size: 1.3rem; color: var(--deep); }

.status-field { margin: 6px 0 12px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span {
  display: inline-block; padding: 6px 14px; border-radius: 999px; min-height: 40px; line-height: 26px;
  border: 2px solid var(--line); background: var(--paper); font-size: .9rem; cursor: pointer;
}
.seg input:checked + span { background: var(--main); border-color: var(--main); font-weight: 700; }
.seg input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--deep) 45%, transparent); }
.seg-small span { font-size: .85rem; }

.box-block { margin: 16px 0; padding: 12px; border: 2px dashed var(--main); border-radius: var(--radius); background: color-mix(in srgb, var(--soft) 45%, var(--paper)); }
.switch { display: flex; align-items: center; gap: 8px; font-weight: 700; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--deep); }
.box-editor { margin-top: 10px; }
.slots { display: flex; flex-direction: column; gap: 8px; }
.slot {
  display: grid; gap: 6px; align-items: center;
  grid-template-columns: 1fr 1fr auto;
  grid-template-areas: "char char del" "xid xid xid" "qty amount amount" "mine paid paid";
  background: var(--paper); border: 2px solid var(--line); border-radius: 12px; padding: 8px;
}
.s-char { grid-area: char; } .s-xid-wrap { grid-area: xid; } .s-qty-wrap { grid-area: qty; }
.s-amount-wrap { grid-area: amount; }
.unit-wrap { position: relative; }
.unit-wrap input { padding-right: 30px !important; }
.unit-wrap .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .85rem; pointer-events: none; } .s-chk:nth-of-type(1) { grid-area: mine; } .s-chk:nth-of-type(2) { grid-area: paid; } .s-del { grid-area: del; }
@media (min-width: 760px) {
  .slot { grid-template-columns: 1.2fr 1.6fr .6fr 1fr auto auto auto; grid-template-areas: "char xid qty amount mine paid del"; }
}
.s-xid-wrap { position: relative; }
.s-xid-wrap .at { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.s-xid-wrap input { padding-left: 28px !important; }
.s-chk { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; white-space: nowrap; cursor: pointer; }
.s-chk input { width: 20px; height: 20px; accent-color: var(--deep); }
.s-del { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--line); background: var(--paper); color: var(--danger); font-size: 1.2rem; cursor: pointer; }
.slot.is-mine { border-color: var(--main); background: color-mix(in srgb, var(--soft) 60%, var(--paper)); }
.slot-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.slot-summary { margin: 8px 0 0; font-size: .9rem; }
.slot-summary .warn { color: var(--danger); font-weight: 700; }

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.form-actions .btn-main { min-width: 180px; }
@media (max-width: 599px) { .form-actions .btn { flex: 1 1 100%; } }
@media (max-width: 380px) { .app { padding-left: 10px; padding-right: 10px; } }

/* ---------- 一覧 ---------- */
.filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.f-field { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.f-field > span { font-size: .75rem; }
.filters select { padding: 6px 4px 6px 8px; font-size: .85rem; min-height: 40px; }
.f-search { grid-column: 1 / -1; }
@media (min-width: 760px) { .filters { grid-template-columns: repeat(3, 1fr) 1.5fr; } .f-search { grid-column: auto; } }
.list-meta { margin: 4px 0 12px; font-size: .9rem; color: var(--muted); }
.list-meta strong { color: var(--deep); font-size: 1.05rem; }

.cards { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 760px) { .cards { grid-template-columns: 1fr 1fr; } }
.card {
  position: relative; background: #fff; border-radius: 6px; padding: 18px 14px 12px;
  box-shadow: var(--shadow); border: 1px solid color-mix(in srgb, var(--line) 70%, #fff);
}
.card::before { /* マスキングテープ */
  content: ""; position: absolute; top: -9px; left: 50%; width: 76px; height: 18px; transform: translateX(-50%) rotate(-3deg);
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.4) 0 5px, transparent 5px 10px), color-mix(in srgb, var(--main) 70%, transparent);
}
.card:nth-child(even)::before { transform: translateX(-50%) rotate(2deg); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-work { font-size: .8rem; color: var(--muted); margin: 0; }
.card-title { margin: 0; font-size: 1.05rem; line-height: 1.5; word-break: break-word; }
.card-price { text-align: right; white-space: nowrap; }
.card-price strong { font-size: 1.2rem; color: var(--deep); display: block; line-height: 1.3; }
.card-price small { color: var(--muted); font-size: .75rem; }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 8px 0 0; padding: 0; list-style: none; font-size: .82rem; color: var(--muted); }
.card-memo { margin: 6px 0 0; font-size: .85rem; white-space: pre-wrap; word-break: break-word; border-left: 3px solid var(--line); padding-left: 8px; }
.card-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; }
.stamp {
  display: inline-block; white-space: nowrap; border: 2px solid currentColor; border-radius: 8px; padding: 0 8px;
  font-size: .8rem; font-weight: 700; transform: rotate(-4deg); background: rgba(255,255,255,.7);
}
.st-reserved { color: #b0661a; } .st-paid { color: #2f7d63; } .st-arrived { color: var(--deep); }
.card-btns { display: flex; gap: 6px; margin-left: auto; }
.mini-btn { border: 2px solid var(--line); background: var(--paper); border-radius: 999px; padding: 4px 12px; font-size: .82rem; cursor: pointer; min-height: 36px; font-weight: 700; white-space: nowrap; }
.mini-btn.next { border-color: var(--main); background: var(--soft); }

.card-box { margin-top: 10px; border-top: 2px dotted var(--line); padding-top: 8px; }
.card-box summary { cursor: pointer; font-size: .85rem; font-weight: 700; color: var(--deep); }
.box-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: .85rem; }
.box-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.b-char { font-weight: 700; min-width: 5em; }
.b-who { flex: 1 1 auto; min-width: 0; word-break: break-all; }
.b-who a { color: var(--deep); }
.b-amt { white-space: nowrap; }
.tag { display: inline-block; font-size: .72rem; padding: 0 8px; border-radius: 999px; background: var(--soft); white-space: nowrap; border: 0; line-height: 1.8; }
.tag.unpaid { background: #ffe9d6; color: #9a4f12; }
.tag-btn { cursor: pointer; font-weight: 700; min-height: 32px; padding: 0 12px; border: 1px solid currentColor; }

.empty { text-align: center; padding: 32px 0; }

/* ---------- 集計 ---------- */
.summary { display: grid; gap: 16px; }
.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 599px) { .sticky { padding: 10px; } .sticky .big { font-size: 1.25rem; } }
@media (min-width: 900px) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.sticky {
  background: color-mix(in srgb, var(--soft) 70%, #fff); padding: 14px; border-radius: 4px;
  box-shadow: var(--shadow); transform: rotate(-.6deg);
}
.sticky:nth-child(even) { transform: rotate(.6deg); background: #fffbe8; }
.sticky h3 { margin: 0; font-size: .85rem; font-weight: 700; }
.sticky .big { font-size: 1.6rem; font-weight: 700; color: var(--deep); line-height: 1.4; }
.sticky p { margin: 0; font-size: .8rem; color: var(--muted); }
.memo-card { background: rgba(255,255,255,.9); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 16px; }
.summary .memo-card { margin-bottom: 0; }
.month-pick { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.month-pick select { width: auto; }
.bars { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.bar-label { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; }
.bar-label span:first-child { word-break: break-word; }
.bar-label span:last-child { font-weight: 700; white-space: nowrap; }
.bar { height: 12px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--deep); }
.upcoming { list-style: none; padding: 0; margin: 6px 0 0; }
.upcoming li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.upcoming li span:last-child { white-space: nowrap; font-weight: 700; }

/* ---------- 作品・キャラの登録 ---------- */
.inline-add { display: flex; gap: 8px; margin: 0 0 14px; }
.inline-add input { flex: 1 1 auto; min-width: 0; }
.inline-add .btn { flex: 0 0 auto; }
.works { display: grid; gap: 14px; }
@media (min-width: 760px) { .works { grid-template-columns: 1fr 1fr; } }
.work-card { margin-bottom: 0; }
.work-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.work-name { border: 0; background: none; padding: 0; font-weight: 700; font-size: 1.05rem; color: var(--deep); text-align: left; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 4px; word-break: break-word; }
.work-count { font-size: .78rem; color: var(--muted); white-space: nowrap; margin-right: auto; }
.chips { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; background: var(--soft); border-radius: 999px; padding: 0 2px 0 12px; }
.chip-name { border: 0; background: none; padding: 6px 2px; cursor: pointer; font-size: .9rem; }
.chip-del { border: 0; background: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; color: var(--muted); font-size: 1rem; }
.chip-del:hover { color: var(--danger); }
.work-card .inline-add { margin: 0; }
.work-card .inline-add .btn { min-height: 44px; padding: 6px 14px; font-size: .9rem; }

.name-dialog { border: 0; border-radius: var(--radius); padding: 20px; width: min(420px, calc(100% - 32px)); background: var(--paper); color: var(--text); box-shadow: var(--shadow); }
.name-dialog::backdrop { background: rgba(60, 40, 50, .35); }
.name-dialog input { margin: 8px 0 14px; }

/* ---------- 設定 ---------- */
.color-presets { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.swatch {
  width: 54px; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: transparent; cursor: pointer; font-size: .75rem; padding: 0;
}
.swatch i { width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); display: block; }
.swatch.is-active i { box-shadow: 0 0 0 3px var(--deep); }
.custom-color { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: .9rem; cursor: pointer; }
.custom-color input { width: 48px; height: 40px; border: 0; padding: 0; background: transparent; cursor: pointer; }
.warn-card { border: 2px solid var(--main); }
.dots { margin: 6px 0 10px; padding-left: 1.2em; font-size: .9rem; }
.backup-status { font-size: .9rem; font-weight: 700; }
.file-btn { position: relative; overflow: hidden; margin-top: 10px; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- バナー・トースト・フッター ---------- */
.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 16px;
  background: #fffbe8; border: 2px dashed #e7c65a; border-radius: 12px; padding: 10px 12px; font-size: .9rem;
}
.banner p { margin: 0; flex: 1 1 220px; }
.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; max-width: calc(100% - 32px); text-align: center;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 760px) { .toast { bottom: 32px; } }
.app-footer { text-align: center; font-size: .78rem; color: var(--muted); margin-top: 16px; }

/* ---------- 姉妹サイト「おたく素材」バナー（推しカラーに関係なくブログの配色のまま） ---------- */
.sister { margin: 20px auto 0; max-width: 560px; }
.sister-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 10px; text-decoration: none;
  padding: 10px 14px; border-radius: 12px; color: #614c56; font-size: .82rem; text-align: center;
  background: rgba(255, 252, 253, .7); border: 1px dashed #f3c3d6;
}
.sister-banner:hover { background: #fffcfd; border-color: #ffa8c9; }
.sister-banner:focus-visible { outline: 3px solid #e85f92; outline-offset: 3px; }
.sister-label { font-size: .7rem; color: #8d7781; border: 1px solid #f3c3d6; border-radius: 999px; padding: 0 8px; line-height: 1.7; }
.sister-name { font-weight: 700; color: #c94d7f; }
.sister-catch { color: #8d7781; }
.sister-btn { color: #c94d7f; font-weight: 700; white-space: nowrap; }
.sister-btn::after { content: " ›"; }

.footer-links { margin: 6px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 8px; }
.footer-links a { color: var(--deep); }
.contact-note { margin-top: 10px; }
#contact .btn { text-decoration: none; }
