:root {
  color-scheme: dark;
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  background: #171B16;
  color: #B8B4A0;
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }

html, body { width: 100%; min-height: 100%; margin: 0; overflow: hidden; }

body {
  background: #171B16;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

.is-hidden * { animation-play-state: paused !important; }

button, input { font: inherit; }
button { touch-action: manipulation; }

.app { position: fixed; inset: 0; min-height: 100dvh; background: #171B16; }
.app::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 43%, transparent 38%, rgba(5,7,5,.16) 100%),
    linear-gradient(to bottom, rgba(255,255,255,.012), transparent 24%, rgba(0,0,0,.045));
}

.swamp-host { position: absolute; inset: 0; }
.swamp-host .swamp { width: 100%; height: 100%; }

.bar {
  position: absolute;
  inset: auto 0 0;
  height: calc(92px + env(safe-area-inset-bottom));
  padding: 14px max(18px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(18px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 1fr 88px 1fr;
  align-items: center;
  gap: 10px;
  background: linear-gradient(
    to bottom,
    rgba(45,53,42,0) 0,
    rgba(45,53,42,.68) 34%,
    rgba(45,53,42,.96) 72%,
    #2D352A 100%
  );
  border-top: 0;
  z-index: 5;
}

.bar button { color: #B8B4A0; border: 0; background: none; letter-spacing: .08em; }
.bar-side {
  position: relative;
  min-height: 48px;
  padding: 10px 5px 8px;
  color: #9DA08E !important;
  font-size: 11px;
  letter-spacing: .16em !important;
  opacity: .82;
  transition: color .7s ease, opacity .7s ease, transform .7s ease;
}
.bar-side:first-child { text-align: left; }
.bar-side:last-child { text-align: right; }
.bar-side::after {
  content: "";
  display: block;
  width: 24px;
  margin-top: 7px;
  border-top: 1px solid rgba(184,180,160,.2);
  transition: width .8s ease, border-color .8s ease;
}
.bar-side:first-child::after { margin-right: auto; }
.bar-side:last-child::after { margin-left: auto; }
.bar-side:active { color: #C6C1A6 !important; opacity: 1; transform: translateY(1px); }
.bar-side:active::after { width: 34px; border-color: rgba(198,193,166,.42); }

.feed-button {
  position: relative;
  width: 82px;
  height: 82px;
  justify-self: center;
  border: 1px solid #77816C !important;
  border-radius: 50%;
  background: #454F3E !important;
  color: #D3CFBB !important;
  font-size: 12px;
  line-height: 1.45;
  transform: translateY(-13px);
  transition: background-color .8s ease, border-color .8s ease, transform .8s ease;
  touch-action: none;
}
.feed-button span { display: block; }
.feed-button small {
  display: block;
  margin-top: 3px;
  color: #969988;
  font-size: 8px;
  font-weight: 400;
  letter-spacing: .08em;
}

.feed-button.is-holding {
  background: #394232 !important;
  border-color: #929A82 !important;
  transform: translateY(-13px) scale(.96);
}

.bar[aria-disabled="true"] { pointer-events: none; }
.bar[aria-disabled="true"] button { opacity: .32; }

.shape-note {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: calc(122px + env(safe-area-inset-bottom));
  width: min(80vw, 360px);
  transform: translateX(-50%);
  color: #B8B4A0;
  text-align: center;
  font-size: 14px;
  letter-spacing: .12em;
  opacity: 0;
  pointer-events: none;
}

.shape-note.show { animation: shapeNote 5s ease both; }
@keyframes shapeNote { 0%,10% { opacity: 0; } 24%,70% { opacity: 1; } 100% { opacity: 0; } }

.purchase-offer {
  position: absolute;
  z-index: 9;
  left: 50%;
  bottom: calc(108px + env(safe-area-inset-bottom));
  width: min(calc(100% - 32px), 430px);
  padding: 18px;
  transform: translateX(-50%);
  color: #A9AA99;
  background: rgba(22, 27, 21, .96);
  border: 1px solid #4A5542;
  box-shadow: 0 18px 44px rgba(0,0,0,.28);
  animation: offerIn 2.2s ease both;
}
.purchase-offer[hidden] { display: none; }
.purchase-offer p { margin: 0 0 8px; font-size: 12px; line-height: 1.9; letter-spacing: .03em; }
.purchase-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 15px; }
.purchase-actions a, .quiet-link {
  display: inline-block;
  padding: 11px 14px;
  color: #D3CFBB;
  background: #4A5542;
  text-decoration: none;
  font-size: 12px;
  letter-spacing: .06em;
}
.purchase-actions button { border: 0; padding: 10px 2px; color: #858B79; background: none; font-size: 12px; }
@keyframes offerIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.onboarding {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 34px 26px max(40px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(23,27,22,.12), rgba(15,18,14,.96) 62%);
}
.onboarding[hidden] { display: none; }
.onboarding-copy { width: min(100%, 430px); }
.eyebrow { margin: 0 0 9px; color: #777E6D; font-size: 11px; letter-spacing: .2em; }
.onboarding h1 { margin: 0 0 20px; color: #D3CFBB; font-size: 24px; font-weight: 400; letter-spacing: .15em; }
.onboarding p { color: #939686; font-size: 13px; line-height: 2; }
.home-note { margin-top: 22px; padding-top: 18px; border-top: 1px solid rgba(89,98,79,.46); }
.home-note > p:first-child { margin: 0 0 10px; color: #777E6D; font-size: 11px; }

.quiet-button, .place-button, .danger-button, .text-button, .close-button {
  border: 0;
  color: #C5C1AE;
  background: #454F3E;
  padding: 12px 16px;
  letter-spacing: .08em;
  font-size: 13px;
}
.place-button { width: 100%; margin-top: 19px; padding: 16px; background: #59634F; border: 1px solid #6B7560; }
.quiet-button { border: 1px solid #59624F; background: transparent; }
.install-help { min-height: 1.8em; margin: 7px 0; font-size: 11px !important; color: #737A69 !important; }

.sheet {
  width: min(100%, 620px);
  height: min(90dvh, 760px);
  max-width: none;
  max-height: none;
  margin: auto auto 0;
  padding: 0;
  color: #B8B4A0;
  background: #171B16;
  border: 1px solid #454F3E;
  border-radius: 8px 8px 0 0;
  user-select: text;
  -webkit-user-select: text;
}
.sheet:focus { outline: none; }
.sheet::backdrop { background: rgba(6,8,6,.72); backdrop-filter: blur(2px); }
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 18px 14px;
  background: #171B16;
  border-bottom: 1px solid #30382C;
}
.sheet h2 { margin: 0; color: #C6C1A6; font-size: 16px; font-weight: 400; letter-spacing: .13em; }
.close-button { padding: 8px; color: #858B79; background: none; font-size: 12px; }

.catalog {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
  overflow: auto;
}
.catalog[hidden] { display: none; }
.catalog-item { min-width: 0; padding: 0; color: inherit; text-align: left; border: 1px solid #2E362B; background: #11140F; }
.catalog-item.is-seen { border-color: #364031; }
.catalog-item.is-unseen { border-color: #242B21; }
.catalog-visual { aspect-ratio: 80 / 52; background: #0F120E; }
.catalog-name { min-height: 48px; padding: 11px 10px; color: #AAA894; font-size: 11px; line-height: 1.7; letter-spacing: .04em; }
.is-unseen .catalog-name { color: #686E60; }
.unknown-card { width: 100%; height: 100%; background: #0F120E; position: relative; }
.unknown-card::after { content: ""; position: absolute; left: 18%; right: 18%; bottom: 31%; border-top: 1px solid #252C22; }
.catalog-observe { cursor: pointer; transition: border-color .3s ease, background-color .3s ease; }
.catalog-observe:active { background: #151A13; border-color: #59624F; }
.catalog-observation {
  min-height: calc(100% - 62px);
  padding: clamp(28px, 8vh, 70px) 24px 34px;
  text-align: center;
  outline: none;
}
.catalog-observation[hidden] { display: none; }
.catalog-observation-visual {
  width: min(100%, 430px);
  margin: 0 auto 24px;
  border: 1px solid #30382C;
  background: #0F120E;
}
.catalog-observation-visual svg { display: block; width: 100%; height: auto; }
.catalog-observation p { margin: 0 0 28px; color: #AAA894; font-size: 13px; letter-spacing: .08em; }

.about-body { padding: 2px 20px calc(34px + env(safe-area-inset-bottom)); overflow: auto; }
.about-body section { padding: 21px 0; border-bottom: 1px solid #2B3228; }
.about-body h3 { margin: 0 0 12px; color: #A6AC96; font-size: 13px; font-weight: 400; letter-spacing: .11em; }
.about-body p { margin: 9px 0; color: #7F8574; font-size: 12px; line-height: 1.9; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; font-size: 13px; }
.switch-row input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 23px;
  margin: 0;
  background: #242B21;
  border: 1px solid #4B5544;
  border-radius: 999px;
  transition: background-color .35s ease, border-color .35s ease;
}
.switch-row input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #7D8372;
  transition: transform .35s ease, background-color .35s ease;
}
.switch-row input:checked { background: #4A5542; border-color: #6B7560; }
.switch-row input:checked::after { transform: translateX(19px); background: #C6C1A6; }
.visit-days { color: #C6C1A6 !important; font-size: 16px !important; letter-spacing: .12em; }
.text-button { padding-left: 0; color: #80796D; background: none; text-decoration: underline; text-underline-offset: 4px; }
.danger-button { margin-right: 8px; color: #D0BEB3; background: #5A3D36; }
.file-button {
  display: inline-block;
  margin: 8px 6px 0 0;
  padding: 11px 14px;
  color: #B8B4A0;
  border: 1px solid #59624F;
  font-size: 12px;
  letter-spacing: .05em;
  cursor: pointer;
}
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.passphrase-row { display: grid; gap: 7px; color: #8D9280; font-size: 12px; }
.passphrase-row input {
  width: 100%;
  padding: 11px;
  color: #C6C1A6;
  background: #10130F;
  border: 1px solid #3A4334;
  user-select: text;
}
.handoff-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.operation-status { min-height: 1.9em; color: #9CA18E !important; }

button:focus-visible, a:focus-visible, input:focus-visible, .file-button:focus-within {
  outline: 1px solid #A6AC96;
  outline-offset: 3px;
}

.sheet, .catalog, .about-body {
  scrollbar-width: thin;
  scrollbar-color: #4A5442 #171B16;
}
.sheet::-webkit-scrollbar, .catalog::-webkit-scrollbar, .about-body::-webkit-scrollbar { width: 7px; }
.sheet::-webkit-scrollbar-track, .catalog::-webkit-scrollbar-track, .about-body::-webkit-scrollbar-track { background: #171B16; }
.sheet::-webkit-scrollbar-thumb, .catalog::-webkit-scrollbar-thumb, .about-body::-webkit-scrollbar-thumb {
  background: #4A5442;
  border: 2px solid #171B16;
  border-radius: 8px;
}

@media (min-width: 540px) {
  .catalog { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .bar { grid-template-columns: minmax(110px, 180px) 92px minmax(110px, 180px); justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .shape-note.show { animation-duration: 3s; }
}
