/* Atlas of Curiosity — stylesheet
 * paper #F2EFE6 / ink #292A2C。英語セリフ主・日本語細字従 (SPEC §2.3)。
 */
:root {
  --paper: #F2EFE6;
  --ink: #292A2C;
  --ink-ja: #4C4B49;
  --muted: #67625D;
  --graphite: #5B5955;
  --accent: #586F76;
  --gold: #C4AD70;
  --rose: #A66078;
  --starlight: #FCFAF3;
  --veil: rgba(246, 243, 235, 0.92);
  --shadow: 0 10px 40px rgba(60, 55, 45, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.65 "Noto Sans JP", "Hiragino Sans", Meiryo, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.serif { font-family: "EB Garamond", Garamond, Georgia, serif; }

/* ---------- canvas ---------- */
#globe {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#globe:active { cursor: grabbing; }

/* ---------- loading ---------- */
#loading {
  position: fixed; inset: 0; z-index: 100;
  background: var(--paper);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
}
#loading .l-title {
  font-family: "EB Garamond", Garamond, Georgia, serif;
  font-size: 34px; letter-spacing: 0.01em;
}
#loading .l-sub { color: var(--muted); font-size: 12px; letter-spacing: 0.35em; text-transform: uppercase; }
#loading-note { color: var(--muted); font-size: 13px; }
.l-ring {
  width: 54px; height: 54px; border-radius: 50%;
  border: 1px solid rgba(91, 89, 85, 0.3);
  border-top-color: var(--accent);
  animation: spin 1.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .l-ring { animation: none; } }

/* ---------- header ---------- */
header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 22px 0;
  pointer-events: none;
}
header > * { pointer-events: auto; }
.brand { line-height: 1.2; user-select: none; }
.brand .owner {
  font-family: "EB Garamond", Garamond, Georgia, serif;
  font-size: 15px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--muted);
}
.brand h1 {
  margin: 2px 0 0;
  font-family: "EB Garamond", Garamond, Georgia, serif;
  font-weight: 400;
  font-size: clamp(24px, 3.2vw, 38px);
  letter-spacing: 0.005em;
}
.brand h1 em { font-style: italic; }
.brand .sub-ja { font-size: 11.5px; font-weight: 300; color: var(--ink-ja); letter-spacing: 0.45em; margin-top: 1px; }

.top-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* search */
.search-wrap { position: relative; }
#search-input {
  width: 220px; padding: 8px 12px;
  border: 1px solid rgba(91, 89, 85, 0.35);
  border-radius: 20px;
  background: var(--veil);
  font: 400 14px "Noto Sans JP", sans-serif;
  color: var(--ink);
  outline: none;
  transition: width .2s, border-color .2s;
}
#search-input:focus { width: 280px; border-color: var(--accent); }
#search-results {
  display: none;
  position: absolute; top: 42px; right: 0;
  width: 330px; max-height: 50vh; overflow: auto;
  background: var(--veil); backdrop-filter: blur(6px);
  border: 1px solid rgba(91, 89, 85, 0.25);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 40;
}
#search-results button {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; cursor: pointer;
  padding: 8px 10px; border-radius: 7px;
  font: 400 14px "Noto Sans JP", sans-serif; color: var(--ink);
}
#search-results button:hover { background: rgba(88, 111, 118, 0.1); }
#search-results button b { font-family: "EB Garamond", Georgia, serif; font-weight: 500; font-size: 15px; }
#search-results button small { color: var(--ink-ja); font-weight: 300; margin-left: 6px; }
#search-results button em { display: block; font-style: normal; font-size: 11px; color: var(--muted); }
#search-results .empty { padding: 10px; font-size: 13px; color: var(--muted); }
#search-results .focus-free { color: var(--accent); font-size: 13px; }

/* nav buttons */
#nav { display: flex; gap: 6px; }
#nav button, .icon-btn {
  position: relative;
  border: 1px solid rgba(91, 89, 85, 0.3);
  background: var(--veil);
  color: var(--ink);
  border-radius: 18px;
  padding: 7px 14px;
  font: 400 13px "Noto Sans JP", sans-serif;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
#nav button:hover, .icon-btn:hover { border-color: var(--accent); }
#nav button.active { background: var(--accent); color: var(--starlight); border-color: var(--accent); }
#plant-btn {
  background: var(--ink); color: var(--starlight);
  border: 0; border-radius: 18px;
  padding: 7px 16px;
  font: 400 13px "Noto Sans JP", sans-serif;
  cursor: pointer;
}
#plant-btn:hover { background: #3d3e40; }
#inbox-badge {
  position: absolute; top: -5px; right: -4px;
  background: var(--rose); color: #fff;
  font-size: 10px; line-height: 1;
  border-radius: 9px; padding: 3px 5px;
  display: none;
}

/* ---------- HUD bottom ---------- */
#hud-bl {
  position: fixed; left: 20px; bottom: 16px; z-index: 20;
  font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; gap: 3px;
  pointer-events: none;
}
#stats { font-family: "EB Garamond", Georgia, serif; font-size: 13.5px; color: var(--graphite); }
#stats b { font-weight: 500; color: var(--ink); }
.sync { font-size: 11px; }
.sync.ok { color: #6d7f6a; }
.sync.warn { color: #a3652f; }

#hud-br {
  position: fixed; right: 20px; bottom: 16px; z-index: 20;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
#zoom-level {
  font-size: 11px; color: var(--muted);
  letter-spacing: 0.08em;
  background: var(--veil);
  padding: 3px 10px; border-radius: 10px;
  border: 1px solid rgba(91, 89, 85, 0.18);
}
.zoom-ctrl { display: flex; flex-direction: column; gap: 5px; }
.zoom-ctrl button {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(91, 89, 85, 0.35);
  background: var(--veil);
  font-size: 16px; color: var(--ink);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.zoom-ctrl button:hover { border-color: var(--accent); }

/* ---------- hover card ---------- */
#hover-card {
  display: none;
  position: fixed; z-index: 30;
  max-width: 290px;
  background: var(--veil); backdrop-filter: blur(5px);
  border: 1px solid rgba(91, 89, 85, 0.25);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 12px 15px;
  pointer-events: none;
}
#hover-card .hc-type { font-size: 10.5px; color: var(--muted); letter-spacing: 0.1em; }
#hover-card .hc-en { font-family: "EB Garamond", Georgia, serif; font-size: 19px; line-height: 1.25; }
#hover-card .hc-ja { font-size: 12px; font-weight: 300; color: var(--ink-ja); margin-bottom: 4px; }
#hover-card .hc-sum { font-size: 12.5px; color: var(--ink-ja); line-height: 1.55; }
#hover-card .hc-sum.en { font-family: "EB Garamond", Georgia, serif; font-size: 13px; color: var(--muted); }
#hover-card .hc-rel { font-size: 11.5px; color: var(--accent); margin-top: 6px; font-family: "EB Garamond", Georgia, serif; }

/* ---------- detail drawer ---------- */
#drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 35;
  width: min(430px, 100vw);
  background: var(--veil); backdrop-filter: blur(10px);
  border-left: 1px solid rgba(91, 89, 85, 0.2);
  box-shadow: -8px 0 40px rgba(60, 55, 45, 0.12);
  padding: 26px 28px 40px;
  overflow-y: auto;
  transform: translateX(105%);
  transition: transform .28s ease;
}
@media (prefers-reduced-motion: reduce) { #drawer { transition: none; } }
#drawer.open { transform: none; }
#drawer .close, #panel .close {
  position: absolute; top: 12px; right: 14px;
  width: 34px; height: 34px;
  border: 0; background: none;
  font-size: 20px; color: var(--muted); cursor: pointer;
  border-radius: 50%;
}
#drawer .close:hover, #panel .close:hover { background: rgba(0,0,0,0.05); }
.d-type { font-size: 11px; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 4px; }
.d-prov { background: rgba(88,111,118,0.12); border-radius: 8px; padding: 2px 8px; margin-left: 6px; font-size: 10.5px; }
.d-en { font-family: "EB Garamond", Georgia, serif; font-weight: 400; font-size: 28px; margin: 0; line-height: 1.2; }
.d-ja { font-size: 13px; font-weight: 300; color: var(--ink-ja); margin: 2px 0 8px; }
.d-interest { font-size: 13px; color: var(--gold); letter-spacing: 2px; margin-bottom: 10px; }
.d-sum { font-size: 14px; line-height: 1.75; margin: 6px 0; }
.d-sum.en { font-family: "EB Garamond", Georgia, serif; color: var(--muted); font-size: 14.5px; }
.d-note {
  background: rgba(196, 173, 112, 0.1);
  border-left: 2px solid var(--gold);
  padding: 10px 12px; margin: 10px 0;
  font-size: 13.5px; white-space: pre-wrap;
}
.d-label { font-size: 11px; letter-spacing: 0.12em; color: var(--muted); margin: 16px 0 6px; text-transform: uppercase; }
.d-terr { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 5px;
  border: 1px solid rgba(91, 89, 85, 0.3);
  border-radius: 14px; padding: 3px 11px;
  font-family: "EB Garamond", Georgia, serif; font-size: 13.5px;
}
.chip small { font-family: "Noto Sans JP", sans-serif; font-weight: 300; font-size: 10.5px; color: var(--ink-ja); }
.chip.suggested { border-style: dashed; color: #7a683c; }
.chip em { font-style: normal; font-size: 9.5px; color: var(--rose); margin-left: 2px; }
.d-rels { list-style: none; margin: 0; padding: 0; }
.d-rels li { padding: 8px 0; border-bottom: 1px solid rgba(91, 89, 85, 0.12); }
.linklike {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: "EB Garamond", Georgia, serif; font-size: 15.5px; color: var(--accent);
  text-align: left;
}
.linklike:hover { text-decoration: underline; }
.linklike small { font-family: "Noto Sans JP", sans-serif; font-weight: 300; font-size: 11px; color: var(--ink-ja); }
.rel-meta { font-size: 11px; color: var(--muted); }
.rel-reason { font-size: 12.5px; color: var(--ink-ja); }
.d-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.d-meta { margin-top: 14px; font-size: 11px; }

.btn {
  border: 1px solid var(--accent);
  background: var(--accent); color: var(--starlight);
  border-radius: 16px; padding: 7px 16px;
  font: 400 13px "Noto Sans JP", sans-serif;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: none; color: var(--accent); }
.btn.small { padding: 5px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: wait; }
.soft { color: var(--muted); font-weight: 300; }

/* ---------- focus bar ---------- */
#focus-bar {
  display: none;
  position: fixed; left: 50%; bottom: 58px; transform: translateX(-50%);
  z-index: 25;
  width: min(760px, calc(100vw - 32px));
  background: var(--veil); backdrop-filter: blur(8px);
  border: 1px solid rgba(91, 89, 85, 0.25);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px 16px;
  flex-direction: column; gap: 6px;
}
#focus-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#focus-label { font-size: 13px; flex: 1; min-width: 180px; }
#focus-label b { font-family: "EB Garamond", Georgia, serif; font-size: 15.5px; }
#focus-bar select, #focus-bar label.ck {
  font: 400 12px "Noto Sans JP", sans-serif;
  color: var(--ink);
  border: 1px solid rgba(91,89,85,0.3); border-radius: 10px;
  background: none; padding: 3px 8px;
}
#focus-bar label.ck { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
#focus-list { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
#focus-list button {
  flex: 0 0 auto;
  border: 1px solid rgba(91, 89, 85, 0.25); border-radius: 10px;
  background: none; cursor: pointer;
  padding: 4px 10px; text-align: left;
  font-family: "EB Garamond", Georgia, serif; font-size: 13px; color: var(--ink);
}
#focus-list button:hover { border-color: var(--accent); }
#focus-list button small { display: block; font-family: "Noto Sans JP", sans-serif; font-weight: 300; font-size: 10px; color: var(--ink-ja); }
#focus-list button em { display: block; font-style: normal; font-size: 9.5px; color: var(--muted); }

/* ---------- plant overlay ---------- */
#plant-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 50;
  background: rgba(242, 239, 230, 0.88);
  backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
  padding: 20px;
}
#plant-form {
  width: min(560px, 100%);
  background: var(--starlight);
  border: 1px solid rgba(91, 89, 85, 0.25);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 30px 34px;
}
#plant-form h2 {
  font-family: "EB Garamond", Georgia, serif; font-weight: 400;
  font-size: 26px; margin: 0;
}
#plant-form .p-ja { font-size: 12px; font-weight: 300; color: var(--ink-ja); letter-spacing: 0.3em; margin-bottom: 14px; }
#plant-text {
  width: 100%; min-height: 110px;
  border: 1px solid rgba(91, 89, 85, 0.35); border-radius: 10px;
  padding: 12px 14px;
  font: 400 15px/1.7 "Noto Sans JP", sans-serif;
  resize: vertical;
  background: #fff;
}
#plant-text:focus { outline: 2px solid rgba(88, 111, 118, 0.4); }
#plant-form .p-hint { font-size: 11.5px; color: var(--muted); margin: 8px 0 14px; }
#plant-form .p-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- side panel (inbox/library/discover/settings) ---------- */
#panel {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 36;
  width: min(480px, 100vw);
  background: var(--veil); backdrop-filter: blur(10px);
  border-right: 1px solid rgba(91, 89, 85, 0.2);
  box-shadow: 8px 0 40px rgba(60, 55, 45, 0.1);
  transform: translateX(-105%);
  transition: transform .28s ease;
  display: flex; flex-direction: column;
}
@media (prefers-reduced-motion: reduce) { #panel { transition: none; } }
#panel.open { transform: none; }
#panel-body { padding: 26px 28px 40px; overflow-y: auto; flex: 1; }
#panel-body h2 { font-family: "EB Garamond", Georgia, serif; font-weight: 400; font-size: 26px; margin: 0 0 4px; }
#panel-body h2 small { display: block; font-family: "Noto Sans JP", sans-serif; font-weight: 300; font-size: 12px; color: var(--ink-ja); }
#panel-body h3 { font-size: 14px; font-weight: 500; }
#panel-body .empty { color: var(--muted); font-size: 13.5px; padding: 18px 0; }

.inbox-list { list-style: none; margin: 14px 0 0; padding: 0; }
.inbox-list li {
  border: 1px solid rgba(91, 89, 85, 0.2); border-radius: 12px;
  padding: 13px 15px; margin-bottom: 10px;
  background: rgba(252, 250, 243, 0.65);
}
.inbox-list.done li { opacity: 0.65; }
.cap-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.cap-meta { font-size: 11px; margin: 4px 0 8px; }
.proposal { border-top: 1px dashed rgba(91,89,85,0.25); margin-top: 8px; padding-top: 8px; }
.prop-tag {
  display: inline-block;
  font-size: 10.5px; letter-spacing: 0.06em;
  color: #7a683c; background: rgba(196, 173, 112, 0.16);
  border-radius: 9px; padding: 2px 9px;
}
.chip-btn {
  display: block; margin: 4px 0;
  border: 1px solid rgba(88,111,118,0.4); border-radius: 10px;
  background: none; cursor: pointer;
  padding: 5px 11px; text-align: left;
  font-family: "EB Garamond", Georgia, serif; font-size: 13.5px; color: var(--accent);
}
.chip-btn:hover { background: rgba(88,111,118,0.08); }
.prop-reason { font-size: 11.5px; margin: 2px 0 6px 4px; line-height: 1.5; }
.chip-btn small { font-family: "Noto Sans JP", sans-serif; font-weight: 300; font-size: 11px; color: var(--ink-ja); }

.lib-search {
  width: 100%; padding: 9px 13px;
  border: 1px solid rgba(91, 89, 85, 0.35); border-radius: 10px;
  font: 400 14px "Noto Sans JP", sans-serif;
  background: #fff;
  margin-top: 10px;
}
.lib-list { list-style: none; margin: 0; padding: 0; }
.lib-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 4px 0 10px; }
.small-toggle { font-size: 12px; font-family: "Noto Sans JP", sans-serif; }
.lib-row {
  display: flex; align-items: stretch;
  border-bottom: 1px solid rgba(91,89,85,0.1);
}
.lib-item {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0; text-align: left;
  background: none; border: 0;
  padding: 9px 4px; cursor: pointer;
  min-height: 44px;
}
.lib-item:hover { background: rgba(88,111,118,0.06); }
.lib-item.is-static { cursor: default; opacity: 0.6; }
.lib-item.is-static:hover { background: none; }
.li-actions { display: flex; align-items: center; gap: 4px; padding-left: 4px; }
.li-act {
  border: 1px solid rgba(91, 89, 85, 0.25); border-radius: 9px;
  background: none; cursor: pointer;
  min-width: 34px; min-height: 34px;
  padding: 4px 8px;
  font: 400 13px "Noto Sans JP", sans-serif;
  color: var(--muted);
}
.li-act:hover { border-color: var(--accent); color: var(--accent); background: rgba(88,111,118,0.06); }
.li-act.restore { color: var(--accent); white-space: nowrap; }
.lib-list.archived .li-names b { text-decoration: line-through; text-decoration-color: rgba(91,89,85,0.4); }
.li-glyph { width: 18px; text-align: center; color: var(--graphite); }
.li-names b { font-family: "EB Garamond", Georgia, serif; font-weight: 500; font-size: 15px; }
.li-names small { display: block; font-weight: 300; font-size: 11px; color: var(--ink-ja); }
.li-type { margin-left: auto; font-size: 10.5px; }

.disc-card {
  border: 1px dashed rgba(122, 104, 60, 0.5); border-radius: 14px;
  padding: 16px 18px; margin: 14px 0;
  background: rgba(196, 173, 112, 0.07);
}
.terr-row { display: flex; align-items: baseline; gap: 8px; padding: 6px 0; font-size: 14px; }
.terr-row b { font-family: "EB Garamond", Georgia, serif; font-weight: 500; }
.terr-row small { font-weight: 300; font-size: 11px; color: var(--ink-ja); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; align-self: center; }

.set-block { margin: 18px 0; }
.set-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.set-table td { padding: 6px 8px; border-bottom: 1px solid rgba(91,89,85,0.12); vertical-align: top; }
.set-table td:first-child { color: var(--muted); white-space: nowrap; width: 110px; }

/* forms */
.form label { display: block; margin: 10px 0; font-size: 12.5px; color: var(--muted); }
.form input, .form select, .form textarea {
  display: block; width: 100%;
  margin-top: 3px;
  border: 1px solid rgba(91, 89, 85, 0.35); border-radius: 8px;
  padding: 8px 11px;
  font: 400 14px "Noto Sans JP", sans-serif;
  background: #fff; color: var(--ink);
}
.form textarea { resize: vertical; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; top: 74px; transform: translateX(-50%) translateY(-12px);
  z-index: 60;
  background: var(--ink); color: var(--starlight);
  border-radius: 20px; padding: 9px 22px;
  font-size: 13px;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  max-width: calc(100vw - 40px);
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.warn { background: #8a5a2b; }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  header { padding: 12px 12px 0; flex-wrap: wrap; gap: 8px; }
  .brand h1 { font-size: 21px; }
  .brand .sub-ja { letter-spacing: 0.3em; }
  #search-input { width: 130px; }
  #search-input:focus { width: 180px; }
  #nav button { padding: 7px 10px; font-size: 12px; }
  #hud-bl { bottom: max(12px, env(safe-area-inset-bottom)); }
  #hud-br { bottom: max(12px, env(safe-area-inset-bottom)); }
  #focus-bar { bottom: 70px; }
  #drawer, #panel { width: 100vw; }
  #plant-form { padding: 22px; }
}
