/* ═══ RESET & BASE ═══ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Noto Sans JP', sans-serif; -webkit-font-smoothing: antialiased; }
.screen { display: none; }
.screen.active { display: block; }

/* ═══ BUTTONS ═══ */
.btn-dark {
  background: #2a2118; color: #f7f3ee; border: none; cursor: pointer;
  font-family: 'Noto Sans JP', sans-serif; border-radius: 3px; transition: background .2s;
}
.btn-dark:hover:not(:disabled) { background: #4a3828; }
.btn-dark:disabled { opacity: .35; cursor: default; }
.btn-ghost {
  background: none; border: 1px dashed #ccc; color: #888; cursor: pointer;
  font-family: 'Noto Sans JP', sans-serif; padding: 8px 20px; font-size: 12px;
  border-radius: 3px; transition: all .2s;
}
.btn-ghost:hover { border-color: #8b6914; color: #8b6914; }
.btn-sm { padding: 8px 18px; font-size: 12px; }
.field-label {
  display: block; font-size: 11px; color: #a89880; letter-spacing: 2px;
  margin-bottom: 6px; font-family: 'Noto Sans JP', sans-serif;
}

/* ═══ START SCREEN ═══ */
.root-start {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #f7f3ee; padding: 40px 20px; font-family: 'Noto Sans JP', sans-serif;
}
.start-inner { text-align: center; width: 100%; max-width: 640px; margin: 0 auto; }
.start-title {
  font-family: 'Zen Old Mincho', serif; font-size: 42px; font-weight: 700;
  color: #2a2118; letter-spacing: 8px; line-height: 1.4; margin-bottom: 4px;
}
.start-ruby {
  font-size: 13px; color: #b8a080; letter-spacing: 6px; margin-bottom: 8px;
  font-family: 'Noto Sans JP', sans-serif; font-weight: 300;
}
.start-sub { font-size: 13px; color: #a89880; line-height: 1.8; margin-bottom: 40px; font-weight: 300; }
.grid-select { display: flex; gap: 16px; justify-content: center; margin-bottom: 36px; flex-wrap: wrap; }
.grid-opt {
  background: #fff; border: 1px solid #e0d8cc; border-radius: 4px; padding: 20px 24px;
  cursor: pointer; transition: all .25s; width: 140px; display: flex; flex-direction: column;
  align-items: center; gap: 6px;
}
.grid-opt:hover { border-color: #8b6914; transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.06); }
.grid-opt-label { font-family: 'Zen Old Mincho', serif; font-size: 22px; font-weight: 700; color: #2a2118; }
.grid-opt-sub { font-size: 11px; color: #b8a080; letter-spacing: 1px; }
.grid-opt-preview { display: grid; gap: 3px; margin-top: 8px; width: 60px; }
.grid-opt-cell { aspect-ratio: 1; background: #f0ebe3; border-radius: 1px; }
.start-import { margin-top: 16px; }

/* consent section */
.consent-section {
  max-width: 600px; margin: 28px auto 24px; padding: 20px 24px;
  background: #fff; border: 1px solid #e0d8cc; border-radius: 6px; text-align: center;
}
.consent-philosophy { margin-bottom: 16px; }
.consent-philosophy p { font-size: 12px; color: #8a7e70; line-height: 1.8; }
.philosophy-main {
  font-family: 'Shippori Mincho', serif; font-size: 13px; color: #2a2118;
  line-height: 2; margin-top: 6px; font-weight: 600;
}
.consent-check {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 13px; color: #2a2118; user-select: none;
}
.consent-check input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: #8b6914; cursor: pointer;
}

/* report link */
.report-link {
  display: inline-block; margin-top: 20px; font-size: 11px; color: #aaa;
  text-decoration: none; font-family: 'Noto Sans JP', sans-serif;
  border-bottom: 1px dashed #ccc; padding-bottom: 1px; transition: color .2s;
}
.report-link:hover { color: #c83860; border-bottom-color: #c83860; }

/* guide & terms */
.start-guide {
  max-width: 600px; margin: 0 auto 28px; text-align: left;
}
.guide-section {
  border: 1px solid #e0d8cc; border-radius: 4px; margin-bottom: 10px;
  background: #fff; overflow: hidden;
}
.guide-heading {
  padding: 12px 16px; font-size: 13px; font-weight: 500; color: #2a2118;
  cursor: pointer; letter-spacing: 1px; user-select: none;
  font-family: 'Zen Old Mincho', serif; list-style: none;
}
.guide-heading::-webkit-details-marker { display: none; }
.guide-heading::before {
  content: '▸'; display: inline-block; margin-right: 8px; font-size: 11px;
  transition: transform .2s; color: #b8a080;
}
details[open] > .guide-heading::before { transform: rotate(90deg); }
.guide-body {
  padding: 4px 18px 16px; font-size: 12px; line-height: 1.9; color: #5a5048;
}
.guide-body p { margin-bottom: 6px; }
.guide-body strong { color: #2a2118; font-weight: 500; }
.guide-note {
  margin-top: 8px; padding: 8px 12px; background: #f7f3ee;
  border-radius: 3px; font-size: 11px; color: #8a7e70;
}
.terms-intro { margin-bottom: 10px; color: #7a6e60; }
.terms-list { margin: 0; }
.terms-list dt {
  font-weight: 600; color: #2a2118; font-size: 12px; margin-top: 10px;
  padding-left: 0;
}
.terms-list dd {
  margin-left: 0; margin-top: 3px; font-size: 11.5px; line-height: 1.85;
  color: #5a5048;
}
.import-box { max-width: 500px; margin: 12px auto 0; }
.import-ta {
  width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 3px;
  font-family: monospace; font-size: 11px; resize: vertical; outline: none;
}
.import-ta:focus { border-color: #8b6914; }
.import-actions { display: flex; gap: 8px; margin-top: 8px; justify-content: center; }

/* ═══ EDIT SCREEN ═══ */
.root-edit {
  min-height: 100vh; background: #faf8f5; padding: 24px 20px 100px;
  font-family: 'Noto Sans JP', sans-serif; max-width: 960px; margin: 0 auto;
}
.edit-header { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.edit-h1 { font-family: 'Zen Old Mincho', serif; font-size: 20px; color: #2a2118; letter-spacing: 2px; }
.edit-section { max-width: 640px; margin: 0 auto 24px; }
.title-input {
  width: 100%; padding: 12px 16px; border: 1px solid #d8d0c4; background: #fff;
  font-family: 'Zen Old Mincho', serif; font-size: 17px; color: #2a2118;
  letter-spacing: 2px; text-align: center; border-radius: 3px; outline: none;
}
.title-input:focus { border-color: #8b6914; }
.creator-input {
  width: 100%; padding: 10px 16px; border: 1px solid #d8d0c4; background: #fff;
  font-family: 'Noto Sans JP', sans-serif; font-size: 14px; color: #2a2118;
  text-align: center; border-radius: 3px; outline: none;
}
.creator-input:focus { border-color: #8b6914; }

/* theme selector */
.theme-filter { margin-bottom: 12px; }
.filter-group { margin-bottom: 8px; display: flex; align-items: flex-start; gap: 6px; flex-wrap: wrap; }
.filter-label { font-size: 10px; color: #aaa; letter-spacing: 1px; min-width: 32px; padding-top: 7px; }
.filter-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.filter-chip {
  padding: 4px 10px; border: 1px solid #ddd; border-radius: 12px; background: #fff;
  font-size: 11px; color: #888; cursor: pointer; font-family: 'Noto Sans JP', sans-serif;
  transition: all .2s;
}
.filter-chip:hover { border-color: #aaa; }
.filter-chip.active { border-color: #8b6914; background: #8b6914; color: #fff; }

.theme-details { margin-bottom: 6px; border: 1px solid #e8e2d8; border-radius: 4px; overflow: hidden; }
.theme-summary {
  padding: 8px 12px; font-size: 12px; color: #5a5048; cursor: pointer; user-select: none;
  font-family: 'Noto Sans JP', sans-serif; font-weight: 500; list-style: none; background: #faf8f5;
}
.theme-summary::-webkit-details-marker { display: none; }
.theme-summary::before { content: '▸'; display: inline-block; margin-right: 6px; font-size: 10px; color: #b8a080; transition: transform .2s; }
.theme-details[open] > .theme-summary::before { transform: rotate(90deg); }
.theme-details[open] > .theme-summary { border-bottom: 1px solid #e8e2d8; }
.theme-row { display: flex; gap: 5px; flex-wrap: wrap; padding: 10px; }
.theme-chip {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 5px 6px; border: 2px solid transparent; border-radius: 8px;
  cursor: pointer; background: none; transition: all .2s; min-width: 44px;
}
.theme-chip:hover { border-color: #ddd; }
.theme-chip.active { border-color: #8b6914; background: rgba(139,105,20,.06); }
.tc-swatch {
  width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid #ddd;
  transition: transform .15s; overflow: hidden; display: block;
}
.tc-split { display: flex; border-radius: 50%; overflow: hidden; }
.tc-split span { flex: 1; height: 26px; display: block; }
.tc-quad { display: grid; grid-template-columns: 1fr 1fr; border-radius: 50%; overflow: hidden; }
.tc-quad span { display: block; width: 13px; height: 13px; }
.theme-chip:hover .tc-swatch { transform: scale(1.12); }
.tc-name { font-size: 9px; color: #999; white-space: nowrap; font-family: 'Noto Sans JP', sans-serif; }

/* entry cards */
.pin-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pin-input {
  width: 140px; padding: 8px 12px; border: 1px solid #d8d0c4; border-radius: 3px;
  font-size: 15px; letter-spacing: 6px; text-align: center; outline: none;
  font-family: 'Zen Old Mincho', serif;
}
.pin-input:focus { border-color: #8b6914; }
.pin-hint { font-size: 11px; color: #aaa; }

.font-selector { margin-top: 4px; }
.font-row { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.font-cat-label { font-size: 10px; color: #bbb; letter-spacing: 1px; margin-right: 4px; min-width: 70px; }
.font-chip {
  padding: 5px 12px; border: 1.5px solid #ddd; border-radius: 14px; background: #fff;
  font-size: 12px; color: #555; cursor: pointer; transition: all .2s;
}
.font-chip:hover { border-color: #aaa; }
.font-chip.active { border-color: #8b6914; background: rgba(139,105,20,.06); color: #2a2118; }

.e-font-select {
  padding: 4px 6px; border: 1px solid #e0d8c8; border-radius: 3px; font-size: 11px;
  color: #888; background: transparent; outline: none; min-width: 90px; cursor: pointer;
}

.entry-move-btns { display: flex; flex-direction: column; gap: 2px; padding-top: 2px; }
.move-btn {
  background: none; border: 1px solid #ddd; border-radius: 3px;
  font-size: 9px; color: #aaa; cursor: pointer; padding: 3px 5px;
  line-height: 1; transition: all .2s; user-select: none;
}
.move-btn:hover:not(:disabled) { border-color: #8b6914; color: #8b6914; }
.move-btn:disabled { opacity: .25; cursor: default; }
.move-btn:active:not(:disabled) { background: rgba(139,105,20,.1); }

.btn-save-img, .btn-copy-img { padding: 10px 20px; font-size: 13px; letter-spacing: 1px; }
.btn-copy-img { background: #3a5134; }
.btn-copy-img:hover:not(:disabled) { background: #4a6844; }
.v-actions-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }

@keyframes entryIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
.entries-list { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 5px; }
.entry-card {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  background: #fff; border: 1px solid #e8e2d8; border-left: 5px solid #ddd;
  border-radius: 3px; animation: entryIn .3s ease both; transition: border-color .25s;
}
.entry-card:focus-within { border-color: #c8b898; background: #fefcf8; }
.entry-num { font-family: 'Zen Old Mincho', serif; font-size: 17px; font-weight: 700; min-width: 28px; padding-top: 5px; }
.entry-fields { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.e-input {
  width: 100%; padding: 7px 8px; border: none; border-bottom: 1px solid #e8e2d8;
  font-size: 13px; color: #2a2118; outline: none; background: transparent;
  transition: border-color .2s; font-family: 'Noto Sans JP', sans-serif;
}
.e-input:focus { border-bottom-color: #8b6914; }
.e-input::placeholder { color: #c0b8a8; }
.e-line { font-family: 'Shippori Mincho', serif; font-size: 14px; }
.entry-row { display: flex; gap: 8px; }
.e-title { flex: 1; }
.e-author { flex: 0.8; }
.e-url { flex: 1; font-family: monospace; font-size: 11px; }

/* bottom bar */
.bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(250,248,245,.95); backdrop-filter: blur(8px);
  border-top: 1px solid #e8e2d8; padding: 12px 20px;
  display: flex; align-items: center; justify-content: center; gap: 16px;
}
.count-label { font-size: 12px; color: #a89880; letter-spacing: 1px; }
.btn-preview { padding: 11px 30px; font-size: 13px; letter-spacing: 1px; }

@media (max-width: 500px) { .entry-row { flex-direction: column; gap: 3px; } }

/* ═══ VIEW SCREEN ═══ */
.root-view { min-height: 100vh; padding: 0 0 60px; font-family: 'Shippori Mincho', serif; }
.v-header { text-align: center; margin-bottom: 44px; display: flex; align-items: center; justify-content: center; gap: 18px; }
.v-orn { font-size: 11px; opacity: .5; letter-spacing: 4px; }
.v-title { font-family: 'Zen Old Mincho', serif; font-size: 24px; font-weight: 700; letter-spacing: 5px; position: relative; }
.v-title-line { display: block; width: 50px; height: 1px; margin: 10px auto 0; }
.v-creator { text-align: center; font-family: 'Noto Sans JP', sans-serif; font-size: 13px; letter-spacing: 2px; margin: -28px 0 32px; opacity: .7; }
.v-watermark { text-align: right; font-family: 'Noto Sans JP', sans-serif; font-size: 11px; letter-spacing: 1px; margin: 12px 8px 0; opacity: .3; }
.option-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: #5a5048; user-select: none; font-family: 'Noto Sans JP', sans-serif; }
.option-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: #8b6914; cursor: pointer; }

/* grid */
@keyframes cellIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.v-grid {
  display: grid; max-width: 960px; margin: 0 auto;
  border-left: 1px solid var(--grid-border, rgba(0,0,0,.1));
  border-top: 1px solid var(--grid-border, rgba(0,0,0,.1));
  grid-template-columns: repeat(var(--grid-cols, 4), 1fr);
}
.g-cell {
  aspect-ratio: 1 / 1;
  padding: 12%; 
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start; /* 左寄せ */
  text-align: left;        /* 左寄せ */
  animation: cellIn .45s ease both;
  border-right: 1px solid var(--grid-border, rgba(0,0,0,.1));
  border-bottom: 1px solid var(--grid-border, rgba(0,0,0,.1));
  overflow: hidden;
  box-sizing: border-box;
}
.g-filled:hover { filter: brightness(.92); }
.g-empty { align-items: center; justify-content: center; }
.g-link { text-decoration: none; color: inherit; width: 100%; }
.g-line {
  font-family: 'Shippori Mincho', serif; font-size: 14px; line-height: 1.7;
  display: block; transition: color .2s; word-break: break-all;
}
.g-filled:hover .g-line { color: var(--hov, #8b6914); }
.g-title { display: block; margin-top: 8px; font-size: 12px; letter-spacing: 1px; line-height: 1.4; opacity: 0.8; }

/* bottom */
.v-bottom { max-width: 960px; margin: 44px auto 0; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.share-box { margin-top: 20px; text-align: center; width: 100%; max-width: 520px; }
.share-label { display: block; font-size: 11px; color: #a89880; letter-spacing: 2px; margin-bottom: 6px; font-family: 'Noto Sans JP', sans-serif; }
.share-code-row { display: flex; gap: 8px; }
.share-code-input {
  flex: 1; padding: 10px 12px; border: 1px solid #ccc; border-radius: 3px;
  font-family: monospace; font-size: 12px; color: #555; outline: none; background: #fff;
}
.share-code-input:focus { border-color: #8b6914; }
.share-hint { margin-top: 8px; font-size: 11px; color: #aaa; font-family: 'Noto Sans JP', sans-serif; }

.sns-row { display: flex; gap: 10px; margin-top: 14px; justify-content: center; flex-wrap: wrap; }
.sns-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px;
  border-radius: 3px; font-size: 12px; text-decoration: none;
  font-family: 'Noto Sans JP', sans-serif; transition: opacity .2s;
  cursor: pointer; border: none; color: #fff;
}
.sns-btn:hover { opacity: .8; }
.sns-x { background: #0f1419; }
.sns-bsky { background: #1185fe; }
.sns-hatena { background: #00a4de; }
.sns-copy { background: #555; min-width: 120px; justify-content: center; }

/* capture area */
#capture-area { border-radius: 0; padding: 60px 40px; box-sizing: border-box; }

@media (max-width: 700px) {
  body:not(.is-capturing) .v-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .v-title { font-size: 19px; letter-spacing: 3px; }
  .g-cell { padding: 10%; }
  .start-title { font-size: 32px; letter-spacing: 5px; }
  .start-ruby { font-size: 11px; letter-spacing: 4px; }
  .philosophy-main { font-size: 12px; }
  .v-actions-row { flex-direction: column; gap: 8px; }
  .v-actions-row > * { width: 100%; text-align: center; justify-content: center; }
  .sns-row { gap: 6px; }
  .sns-btn { padding: 8px 12px; font-size: 11px; }
}