:root {
  --paper: #f7f3ea;
  --ink: #2b2723;
  --sub: #7a7066;
  --line: #ddd4c4;
  --accent: #8a4b3c;
  --mincho: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mincho);
  line-height: 1.9;
}
a { color: inherit; }
.wrap { max-width: 760px; margin: 0 auto; padding: 48px 24px 80px; }

header.site { text-align: center; margin-bottom: 56px; }
header.site h1 { font-size: 2rem; letter-spacing: .3em; margin: 0; font-weight: 500; }
header.site p { color: var(--sub); margin: 8px 0 0; font-size: .9rem; letter-spacing: .1em; }
header.site a { text-decoration: none; }

h2.shelf {
  font-size: 1.1rem; font-weight: 500; letter-spacing: .3em;
  border-bottom: 1px solid var(--line); padding-bottom: 8px; margin: 56px 0 24px;
}

.work {
  display: block; text-decoration: none;
  padding: 20px 0; border-bottom: 1px dashed var(--line);
}
.work:hover .work-title { color: var(--accent); }
.work-title { font-size: 1.25rem; transition: color .2s; }
.meta { color: var(--sub); font-size: .85rem; }
.work p { margin: 6px 0 0; }

/* 本棚と背表紙 */
.bookshelf {
  display: flex; align-items: flex-end; gap: 4px; flex-wrap: wrap;
  padding: 24px 16px 0; min-height: 260px;
  background: linear-gradient(#e9e0cf, #e2d7c2);
  border-bottom: 14px solid #6b4a32;
  box-shadow: inset 0 8px 16px rgba(0,0,0,.06), 0 6px 0 #4e3523;
}
.spine {
  position: relative; border: none; cursor: pointer; padding: 14px 0;
  color: #f3ead8; font-family: var(--mincho);
  writing-mode: vertical-rl; display: flex; align-items: center; justify-content: space-between;
  border-radius: 3px 3px 0 0;
  box-shadow: inset 3px 0 0 rgba(255,255,255,.12), inset -3px 0 0 rgba(0,0,0,.2), 2px 0 4px rgba(0,0,0,.15);
  transition: transform .2s ease;
}
.spine::before, .spine::after {
  content: ""; position: absolute; left: 6px; right: 6px; height: 2px; background: rgba(230,200,140,.55);
}
.spine::before { top: 8px; }
.spine::after { bottom: 8px; }
.spine:hover, .spine:focus-visible { transform: translateY(-10px); outline: none; }
.spine-title { font-size: 1rem; letter-spacing: .12em; overflow: hidden; max-height: 75%; }
.spine-sub { font-size: .7rem; opacity: .75; letter-spacing: .1em; }
.shelf-note { color: var(--sub); font-size: .8rem; margin: 10px 0 0; }

/* 感想のポップアップ */
dialog {
  border: none; border-radius: 4px; max-width: 520px; width: 90%;
  padding: 32px; background: var(--paper); color: var(--ink); font-family: var(--mincho);
}
dialog::backdrop { background: rgba(30,22,15,.45); }
dialog h2 { margin: 0; font-weight: 500; font-size: 1.3rem; }
dialog p { white-space: pre-wrap; }
dialog .close {
  font-family: inherit; background: none; border: 1px solid var(--line); color: var(--ink);
  padding: 4px 16px; cursor: pointer; border-radius: 2px; float: right;
}

.read { padding: 18px 0; border-bottom: 1px dashed var(--line); }
.read-title { font-size: 1.1rem; }
.read p { margin: 6px 0 0; white-space: pre-wrap; }

/* 読む画面 */
.reader-bar {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .85rem; color: var(--sub); margin-bottom: 32px;
}
.reader-bar button {
  font-family: inherit; background: none; border: 1px solid var(--line);
  color: var(--ink); padding: 4px 12px; cursor: pointer; border-radius: 2px;
}
.reader-bar button:hover { border-color: var(--accent); color: var(--accent); }
.work-head { text-align: center; margin-bottom: 40px; }
.work-head h1 { font-weight: 500; letter-spacing: .15em; margin: 0; }

.text { font-size: 1.05rem; }
.text h2 { font-size: 1.1rem; font-weight: 500; text-align: center; margin: 48px 0 24px; }
.text p { margin: 0 0 1.2em; text-indent: 1em; }
.text .bouten { text-emphasis: filled sesame; -webkit-text-emphasis: filled sesame; }

/* 縦書き */
.text.vertical {
  writing-mode: vertical-rl;
  height: 75vh; overflow-x: auto; overflow-y: hidden;
  line-height: 2; padding: 8px 0;
}
.text.vertical h2 { margin: 0 2em; }
.text.vertical p { margin: 0 0 0 1em; }

/* 上のバー */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  font-size: 1.3rem; letter-spacing: .25em; font-weight: 600;
}
.topbar .mark { width: 12px; height: 12px; background: var(--accent); }
.page-title { font-size: 2rem; font-weight: 600; letter-spacing: .15em; margin: 0 0 8px; }
.page-lead { color: var(--sub); margin: 0 0 28px; letter-spacing: .05em; }
.has-tabs .wrap { padding-top: 32px; padding-bottom: 120px; }

/* 一覧の行 */
.row {
  display: flex; align-items: center; gap: 16px; width: 100%;
  padding: 18px 0; border: none; border-bottom: 1px solid var(--line);
  background: none; text-align: left; text-decoration: none; cursor: pointer;
  font-family: inherit; color: inherit;
}
.row-bar { width: 6px; align-self: stretch; min-height: 48px; flex-shrink: 0; }
.row-body { display: flex; flex-direction: column; flex: 1; }
.row-title { font-size: 1.15rem; font-weight: 600; transition: color .2s; }
.row:hover .row-title { color: var(--accent); }
.row-summary { margin-top: 4px; font-size: .9rem; }
.badge { font-size: .75rem; color: var(--accent); border: 1px solid var(--accent); padding: 0 8px; white-space: nowrap; }

/* 下のタブ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around;
  background: #fbf9f4; border-top: 1px solid var(--line);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--sub); font-size: .8rem; min-width: 80px;
}
.tabbar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.tabbar a.active { color: var(--accent); }

@media (max-width: 520px) {
  .bookshelf { padding: 16px 8px 0; gap: 3px; }
  .spine { width: 36px !important; }
  .spine-title { font-size: .9rem; }
}

/* 編集・ログイン */
[hidden] { display: none !important; }
.quiet { color: var(--sub); text-decoration: none; }
.quiet:hover { color: var(--accent); }
.small { font-size: .85rem; font-weight: normal; letter-spacing: 0; }
.spacer { flex: 1; }
.wrap.narrow { max-width: 420px; }
.form { display: flex; flex-direction: column; gap: 18px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--sub); }
.form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.form input:not([type=checkbox]):not([type=color]), .form textarea {
  font-family: inherit; font-size: 1rem; color: var(--ink);
  background: #fffdf8; border: 1px solid var(--line); border-radius: 2px; padding: 10px 12px;
}
.form textarea { line-height: 1.8; resize: vertical; }
.form input:focus, .form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form input[type=color] { width: 64px; height: 36px; border: 1px solid var(--line); background: none; padding: 2px; }
.form code { background: #ebe3d4; padding: 0 4px; }
.chapter { border: 1px solid var(--line); padding: 16px; display: flex; flex-direction: column; gap: 12px; margin: 0 0 12px; }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.primary, .danger, .small-btn {
  font-family: inherit; cursor: pointer; border-radius: 2px; padding: 8px 20px; font-size: .95rem;
}
.primary { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.primary:hover { background: var(--accent); border-color: var(--accent); }
.primary:disabled { opacity: .5; cursor: default; }
.danger { background: none; color: #a33; border: 1px solid #c99; }
.danger:hover { background: #a33; color: #fff; }
.small-btn { background: none; color: var(--ink); border: 1px solid var(--line); padding: 4px 12px; font-size: .85rem; align-self: flex-start; }
.small-btn:hover { border-color: var(--accent); color: var(--accent); }
.msg { color: var(--accent); min-height: 1.5em; }
.seg { display: flex; gap: 8px; margin-bottom: 24px; }
.seg button {
  font-family: inherit; font-size: .95rem; cursor: pointer;
  padding: 8px 22px; border-radius: 999px; border: 1px solid var(--line); background: none; color: var(--ink);
}
.seg button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
#list-view .primary { margin-bottom: 8px; }
.topbar .small-btn { align-self: center; }

/* 本人ログイン中だけ出る「編集に戻る」 */
.edit-fab {
  position: fixed; right: 16px; bottom: 24px; z-index: 10;
  background: var(--ink); color: var(--paper); text-decoration: none;
  padding: 10px 18px; border-radius: 999px; font-size: .9rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.edit-fab:hover { background: var(--accent); }
.has-tabs .edit-fab { bottom: calc(84px + env(safe-area-inset-bottom)); }

footer { text-align: center; color: var(--sub); font-size: .8rem; margin-top: 80px; }
