:root {
  color-scheme: light;
  --ink: #28231f;
  --ink-soft: #625950;
  --paper: #f7f0e3;
  --paper-deep: #e8dcc8;
  --paper-light: #fffdf8;
  --line: rgba(85, 68, 52, 0.2);
  --gold: #a36b24;
  --gold-light: #d7aa62;
  --green: #345247;
  --shadow: rgba(55, 43, 32, 0.18);
  --serif: "Noto Serif SC", serif;
  --display: "Cormorant Garamond", "Noto Serif SC", serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #d8ccb9;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 250, 239, 0.72), transparent 28rem),
    radial-gradient(circle at 85% 90%, rgba(117, 94, 63, 0.18), transparent 30rem),
    #d8ccb9;
  font-family: var(--serif);
}

button,
select {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 18px;
}

.site-header,
.workspace,
.site-footer {
  border: 1px solid rgba(89, 70, 50, 0.24);
  background:
    linear-gradient(rgba(255, 253, 247, 0.84), rgba(249, 242, 229, 0.84)),
    repeating-linear-gradient(0deg, transparent 0 4px, rgba(94, 75, 52, 0.025) 4px 5px);
  box-shadow: 0 18px 50px rgba(79, 61, 43, 0.1);
}

.site-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  padding: 25px 30px 23px;
  border-bottom: 0;
}

.eyebrow,
.card-type,
.field-name,
.section-index {
  margin: 0;
  color: var(--gold);
  font-family: var(--display);
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  line-height: 1.3;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-family: var(--display);
  font-size: clamp(3.3rem, 7vw, 5.3rem);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 0.8;
}

.subtitle {
  margin: 11px 0 0;
  color: var(--green);
  font-size: 0.91rem;
  font-weight: 700;
  letter-spacing: 0.28em;
}

.header-note {
  max-width: 30rem;
  margin: 0 0 2px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  line-height: 1.8;
  text-align: right;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(520px, 1.55fr);
  min-height: 720px;
}

.card-panel {
  position: sticky;
  top: 0;
  display: flex;
  max-height: 100vh;
  flex-direction: column;
  justify-content: space-between;
  padding: 25px 28px 23px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 46%, rgba(232, 210, 166, 0.68), transparent 19rem),
    rgba(235, 226, 208, 0.48);
}

.controls {
  position: relative;
  z-index: 2;
}

.select-label {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
}

select,
.draw-button {
  min-height: 43px;
  border: 1px solid rgba(101, 76, 49, 0.28);
  border-radius: 3px;
}

select {
  width: 100%;
  padding: 0 34px 0 12px;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.82);
  font-size: 0.82rem;
}

.draw-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 15px;
  color: #fffaf0;
  background: var(--green);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition:
    background-color 180ms ease,
    transform 180ms ease;
}

.draw-button:hover {
  background: #243f36;
  transform: translateY(-1px);
}

.draw-button:active {
  transform: translateY(1px);
}

.draw-icon {
  color: #e9c782;
  font-size: 1rem;
}

.card-stage {
  position: relative;
  display: grid;
  flex: 1;
  min-height: 0;
  place-items: center;
  padding: 24px 0 18px;
}

.stage-glow {
  position: absolute;
  width: min(80%, 360px);
  aspect-ratio: 1;
  border: 1px solid rgba(166, 113, 43, 0.17);
  border-radius: 50%;
  box-shadow:
    0 0 0 28px rgba(166, 113, 43, 0.025),
    0 0 0 62px rgba(166, 113, 43, 0.018);
}

.tarot-card-frame {
  position: relative;
  width: min(55%, 272px);
  overflow: hidden;
  border: 8px solid #fffef9;
  outline: 1px solid rgba(78, 57, 36, 0.38);
  background: #f3ede0;
  box-shadow:
    0 25px 44px rgba(67, 51, 36, 0.28),
    0 4px 10px rgba(67, 51, 36, 0.14);
  transition:
    transform 300ms ease,
    opacity 250ms ease;
}

.tarot-card-frame::after {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(105, 77, 42, 0.18);
  content: "";
  pointer-events: none;
}

.tarot-card-frame.is-drawing {
  opacity: 0.25;
  transform: translateY(-8px) rotate(-1.5deg) scale(0.98);
}

#card-image {
  display: block;
  width: 100%;
  aspect-ratio: 248.5 / 435.6;
  object-fit: contain;
}

.card-caption {
  position: relative;
  z-index: 2;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.card-caption h2 {
  margin: 6px 0 2px;
  font-size: 1.45rem;
  letter-spacing: 0.15em;
}

.card-title-en {
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--display);
  font-size: 1.16rem;
  font-style: italic;
  letter-spacing: 0.05em;
}

.details-panel {
  padding: 34px clamp(25px, 4vw, 56px) 44px;
  background: rgba(255, 253, 248, 0.44);
}

.details-header {
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.details-header h2 {
  margin: 7px 0 0;
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  letter-spacing: 0.1em;
}

.element-badge {
  padding: 9px 12px;
  border: 1px solid rgba(154, 104, 36, 0.35);
  color: #78521e;
  background: rgba(235, 210, 165, 0.21);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  white-space: nowrap;
}

.details-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.language-toggle {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(52, 82, 71, 0.32);
  border-radius: 3px;
  color: var(--green);
  background: rgba(255, 253, 247, 0.68);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  white-space: nowrap;
  transition:
    color 180ms ease,
    background-color 180ms ease,
    transform 180ms ease;
}

.language-toggle:hover {
  color: #fffaf0;
  background: var(--green);
  transform: translateY(-1px);
}

.language-toggle:active {
  transform: translateY(1px);
}

.metadata-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.55fr) minmax(0, 2.35fr);
  gap: 1px;
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.metadata-item {
  min-width: 0;
  padding: 12px 13px 13px;
  background: rgba(250, 246, 237, 0.88);
}

.metadata-item dt {
  margin-bottom: 5px;
  color: #a58c70;
  font-family: var(--display);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.metadata-item dd {
  margin: 0;
  overflow: hidden;
  color: #625950;
  font-size: 0.72rem;
  letter-spacing: 0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.details-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 34px;
}

.info-section {
  position: relative;
  padding: 24px 0 23px;
  border-bottom: 1px solid var(--line);
}

.info-section:first-child {
  grid-column: 1 / -1;
}

.section-heading {
  display: flex;
  gap: 11px;
  align-items: baseline;
  margin-bottom: 11px;
}

.section-index {
  min-width: 1.5rem;
  color: var(--gold-light);
  font-size: 1.02rem;
}

.section-heading h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.12em;
}

.field-name {
  margin-top: 3px;
  color: #9e8870;
  font-size: 0.61rem;
  letter-spacing: 0.12em;
}

.section-body {
  margin: 0;
  color: #4d453d;
  font-size: 0.88rem;
  letter-spacing: 0.035em;
  line-height: 1.92;
}

.section-body.is-empty {
  color: #a09284;
  font-style: italic;
}

.source-link {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  margin-top: 12px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-decoration: none;
  word-break: break-all;
}

.source-link:hover {
  color: #744510;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.source-link.is-hidden {
  display: none;
}

.source-field {
  color: #a58c70;
  font-family: var(--display);
  letter-spacing: 0.12em;
}

.source-url {
  letter-spacing: 0.02em;
}

.site-footer {
  padding: 12px 24px;
  border-top: 0;
  color: #857463;
  font-size: 0.68rem;
  letter-spacing: 0.13em;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.load-error {
  max-width: 44rem;
  padding: 22px;
  border: 1px solid rgba(132, 57, 43, 0.26);
  color: #7d3329;
  background: rgba(255, 245, 239, 0.62);
  line-height: 1.8;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 24px, 760px);
    padding-top: 12px;
  }

  .site-header {
    display: block;
    padding: 22px 22px 19px;
  }

  .header-note {
    margin-top: 18px;
    text-align: left;
  }

  .workspace {
    display: block;
  }

  .card-panel {
    position: relative;
    max-height: none;
    padding: 20px 20px 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .card-stage {
    height: 500px;
  }

  .tarot-card-frame {
    width: min(58%, 246px);
  }

  .details-panel {
    padding: 28px 23px 34px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .site-header,
  .workspace,
  .site-footer {
    border-right: 0;
    border-left: 0;
  }

  h1 {
    font-size: 4rem;
  }

  .subtitle {
    font-size: 0.78rem;
  }

  .header-note {
    font-size: 0.8rem;
  }

  .control-row {
    display: block;
  }

  .draw-button {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
  }

  .card-stage {
    height: 450px;
  }

  .details-content {
    display: block;
  }

  .details-header {
    align-items: start;
  }

  .details-actions {
    align-items: end;
    flex-direction: column;
  }

  .metadata-grid {
    grid-template-columns: 1fr;
  }
}
