* { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  color-scheme: light;
  --plaster: #ebe7de;
  --bench: #e2ddd2;
  --paper: #f3f0e9;
  --ink: #1f2d2c;
  --muted: #52615d;
  --rule: #c5bfb2;
  --celadon: #4a7169;
  --celadon-deep: #34544d;
  --ember: #b54528;
  --cedar: #7e6248;
  font-family: system-ui, "PingFang SC", "Hiragino Sans", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--plaster);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 8%, #f7f4ec 0, transparent 46%),
    radial-gradient(circle at 86% 90%, #ded8cb 0, transparent 48%),
    var(--plaster);
}

button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
:focus-visible { outline: 2.5px solid var(--celadon); outline-offset: 3px; }

.page {
  width: min(100% - 3rem, 78rem);
  margin-inline: auto;
  padding: clamp(1.5rem, 4.2vh, 3.2rem) 0 3.6rem;
}

/* Header */
.mast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  padding-bottom: 1.35rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: clamp(1.3rem, 3vw, 2.2rem);
}

.brand-group {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  min-width: 0;
}

.brand-emblem {
  flex: none;
  margin-top: 0.2rem;
}

.brand-sub {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

h1, h2, h3 {
  margin: 0;
  font-family: "Hiragino Mincho ProN", "Songti SC", "Noto Serif CJK SC", Georgia, serif;
  font-weight: 400;
}

h1 {
  font-size: clamp(2.1rem, 4.8vw, 3.6rem);
  line-height: 1.12;
  letter-spacing: 0.02em;
}

.brand-copy p {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
  max-width: 52ch;
}

.mast-tools {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.language-picker {
  appearance: none;
  min-height: 40px;
  padding: 0.25rem 1.7rem 0.25rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background:
    linear-gradient(45deg, transparent 50%, currentColor 51%) right 0.84rem center / 0.27rem 0.27rem no-repeat,
    linear-gradient(135deg, currentColor 50%, transparent 51%) right 0.57rem center / 0.27rem 0.27rem no-repeat,
    var(--paper);
  font-size: 0.875rem;
}

.sound-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.25rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  font-size: 0.875rem;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.sound-pill:hover { background: #e5e1d7; }
.sound-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--celadon);
}
.sound-pill[aria-pressed="false"] .sound-dot { background: #9da6a1; }
.sound-state { color: var(--muted); font-size: 0.82rem; }

/* Studio Grid */
.studio {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(20rem, 0.92fr);
  gap: clamp(1.5rem, 3.6vw, 3rem);
  align-items: start;
}

/* Wheel Stage */
.wheel-col {
  display: grid;
  gap: 0.75rem;
}

.stage-frame {
  position: relative;
  border: 1px solid #bdb7a8;
  border-radius: 10px;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 24%, #f4f1ea 0, #e3dfd4 58%, #d4cfc3 100%);
  box-shadow: inset 0 1px 0 #faf8f2, 0 12px 28px #1f2d2c12;
}

.stage-hud {
  position: absolute;
  top: 0.85rem;
  left: 0.9rem;
  right: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 2;
}

.stage-badge, .temp-badge {
  padding: 0.24rem 0.62rem;
  border-radius: 4px;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  background: rgba(243, 240, 233, 0.84);
  border: 1px solid #c5bfb2;
  color: var(--ink);
  backdrop-filter: blur(4px);
}

.temp-badge {
  background: rgba(45, 29, 24, 0.86);
  border-color: #6b4130;
  color: #fbd8b2;
  font-variant-numeric: tabular-nums;
}

#wheel-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 8 / 7;
  height: auto;
  touch-action: none;
  cursor: grab;
  user-select: none;
}

#wheel-canvas:active { cursor: grabbing; }
#wheel-canvas[data-mode="paint"] { cursor: crosshair; }
#wheel-canvas[data-mode="ring"] { cursor: pointer; }

.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.62rem 0.75rem;
  border-top: 1px solid var(--rule);
  background: rgba(235, 231, 222, 0.88);
}

.stage-bar-left {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.stage-btn {
  min-height: 36px;
  padding: 0.28rem 0.7rem;
  border: 1px solid #bcb5a7;
  border-radius: 5px;
  background: var(--paper);
  font-size: 0.83rem;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.stage-btn:hover:not(:disabled) {
  background: #e5e0d5;
  border-color: #9e9788;
}

.ring-btn {
  border-color: var(--celadon);
  color: var(--celadon-deep);
  background: #e3ece9;
}

.ring-btn:hover:not(:disabled) {
  background: #d5e3df;
}

.studio-note {
  margin: 0;
  padding: 0.55rem 0.8rem;
  border-left: 2.5px solid var(--celadon);
  background: rgba(243, 240, 233, 0.7);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  min-height: 2.6rem;
}

.noscript {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  border: 1px solid var(--ember);
  color: var(--ember);
  background: #f9ebe6;
  border-radius: 6px;
}

/* Workbench Controls */
.bench-col {
  background: var(--bench);
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
}

.studio-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--rule);
  background: #dad4c7;
}

.studio-tabs [role="tab"] {
  min-height: 46px;
  padding: 0.55rem 0.5rem;
  border: 0;
  border-right: 1px solid var(--rule);
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  transition: background-color 150ms ease, color 150ms ease;
}

.studio-tabs [role="tab"]:last-child { border-right: 0; }

.studio-tabs [role="tab"][aria-selected="true"] {
  background: var(--bench);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--celadon);
}

.bench-panel {
  padding: 1.15rem 1.2rem 1.3rem;
  display: grid;
  gap: 1.15rem;
}

.panel-hint {
  margin: 0;
  font-size: 0.87rem;
  line-height: 1.5;
  color: var(--muted);
}

.small-hint { margin-top: 0.25rem; font-size: 0.82rem; }

.control-block {
  display: grid;
  gap: 0.5rem;
}

.control-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.block-label {
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip-btn, .toggle-btn {
  min-height: 38px;
  padding: 0.35rem 0.78rem;
  border: 1px solid #b8b2a4;
  border-radius: 6px;
  background: var(--paper);
  font-size: 0.86rem;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.chip-btn:hover, .toggle-btn:hover {
  background: #e8e3d8;
  border-color: #938c7e;
}

.chip-btn.is-active, .toggle-btn[aria-pressed="true"] {
  background: var(--celadon);
  border-color: var(--celadon-deep);
  color: #f4f7f5;
}

.ghost-btn {
  background: transparent;
  border-style: dashed;
}

/* Swatches */
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.glaze-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.brush-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.swatch-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.38rem 0.6rem;
  border: 1px solid #bcb6a8;
  border-radius: 6px;
  background: var(--paper);
  font-size: 0.84rem;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.swatch-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.swatch-card i {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--swatch);
  border: 1px solid rgba(31, 45, 44, 0.25);
}

.swatch-card i.no-brush {
  background: linear-gradient(135deg, transparent 45%, #8f8a7e 46% 54%, transparent 55%), #ece8de;
}

.swatch-card:has(input:checked) {
  border-color: var(--celadon);
  background: #e1eae6;
  font-weight: 600;
}

.swatch-card:has(input:focus-visible) {
  outline: 2.5px solid var(--celadon);
  outline-offset: 2px;
}

/* Pill radios */
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.pill-radio {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.3rem 0.78rem;
  border: 1px solid #b8b2a4;
  border-radius: 999px;
  background: var(--paper);
  font-size: 0.84rem;
  cursor: pointer;
}

.pill-radio input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pill-radio:has(input:checked) {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.pill-radio:has(input:focus-visible) {
  outline: 2.5px solid var(--celadon);
  outline-offset: 2px;
}

/* Kiln Mode Cards */
.kiln-cards {
  display: grid;
  gap: 0.5rem;
}

.kiln-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #bcb6a8;
  border-radius: 7px;
  background: var(--paper);
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.kiln-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.kiln-dot {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-top: 0.22rem;
}
.kiln-dot.electric { background: #5a8289; }
.kiln-dot.wood { background: #b54528; }
.kiln-dot.raku { background: #2c2827; box-shadow: inset 0 0 0 2px #9a8569; }

.kiln-copy { display: grid; gap: 0.18rem; }
.kiln-copy strong { font-size: 0.9rem; font-weight: 600; }
.kiln-copy small { font-size: 0.8rem; color: var(--muted); line-height: 1.4; }

.kiln-card:has(input:checked) {
  border-color: var(--ember);
  background: #f5ece6;
}

.kiln-card:has(input:focus-visible) {
  outline: 2.5px solid var(--ember);
  outline-offset: 2px;
}

.fire-btn {
  min-height: 46px;
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid #8c321a;
  border-radius: 7px;
  background: var(--ember);
  color: #fdf6ee;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: background-color 160ms ease, transform 120ms ease;
}

.fire-btn:hover:not(:disabled) { background: #9d3a20; }
.fire-btn:active:not(:disabled) { transform: translateY(1px); }

/* Name & Final Actions */
.name-row {
  display: flex;
  gap: 0.45rem;
}

#vessel-name {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0.4rem 0.7rem;
  border: 1px solid #b5afa0;
  border-radius: 6px;
  background: var(--paper);
}

.dice-btn {
  min-width: 40px;
  min-height: 40px;
  border: 1px solid #b5afa0;
  border-radius: 6px;
  background: var(--paper);
}

.dice-btn:hover { background: #e8e2d5; }

.final-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.primary-action, .secondary-action {
  min-height: 42px;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}

.primary-action {
  border: 1px solid var(--celadon-deep);
  background: var(--celadon);
  color: #f4f7f5;
}
.primary-action:hover:not(:disabled) { background: var(--celadon-deep); }

.secondary-action {
  border: 1px solid #b5afa0;
  background: var(--paper);
}
.secondary-action:hover:not(:disabled) { background: #e7e1d5; }

/* Shelf & Marks */
.shelf-section {
  margin-top: clamp(2.2rem, 5vw, 3.6rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.shelf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.shelf-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
}

.shelf-title-wrap h2 {
  font-size: clamp(1.35rem, 2.5vw, 1.9rem);
}

.shelf-count {
  font-size: 0.85rem;
  color: var(--muted);
}

.marks-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 38px;
  padding: 0.3rem 0.8rem;
  border: 1px solid #bcb5a7;
  border-radius: 6px;
  background: var(--paper);
  font-size: 0.86rem;
}
.marks-btn:hover { background: #e5e0d4; }
.chop-dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--ember);
}
.marks-badge {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.marks-drawer {
  margin-bottom: 1.25rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
}

.marks-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.marks-head h3 { font-size: 1.15rem; }
.marks-head p { margin: 0; font-size: 0.85rem; color: var(--muted); }

.marks-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.mark-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid #d5cfc2;
  border-radius: 6px;
  background: #ece8df;
  opacity: 0.56;
}

.mark-item.is-earned {
  opacity: 1;
  background: #f8f5ee;
  border-color: #b7aa92;
}

.mark-seal {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1.5px solid #9e9788;
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.mark-item.is-earned .mark-seal {
  border-color: var(--ember);
  background: #f5e6e0;
  color: var(--ember);
  font-weight: 700;
}

.mark-copy { display: grid; gap: 0.15rem; }
.mark-copy strong { font-size: 0.88rem; }
.mark-copy small { font-size: 0.78rem; color: var(--muted); line-height: 1.4; }

.shelf-empty {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.9rem;
  align-items: end;
}

.vessel-card {
  position: relative;
  display: grid;
  gap: 0.35rem;
  padding: 0.55rem;
  border: 1px solid #c5bfb2;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--paper);
  text-align: center;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.vessel-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 18px #1f2d2c18;
}

.vessel-load {
  border: 0;
  background: transparent;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  text-align: center;
  width: 100%;
}

.vessel-load canvas {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  display: block;
  border-radius: 5px;
  background: linear-gradient(180deg, #edeae1, #e2ddd1);
}

.vessel-load strong {
  font-family: "Hiragino Mincho ProN", "Songti SC", "Noto Serif CJK SC", Georgia, serif;
  font-weight: 400;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vessel-load small {
  font-size: 0.76rem;
  color: var(--muted);
}

.vessel-remove {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 24px;
  height: 24px;
  border: 1px solid #c5bfb2;
  border-radius: 50%;
  background: rgba(243, 240, 233, 0.9);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
  display: grid;
  place-items: center;
}

.vessel-remove:hover {
  background: #f4dfda;
  border-color: var(--ember);
  color: var(--ember);
}

.cedar-ledge {
  height: 14px;
  border-radius: 3px;
  background: linear-gradient(180deg, #987a5b, var(--cedar) 45%, #5c4531);
  box-shadow: 0 6px 14px #1f2d2c1f;
}

@media (max-width: 920px) {
  .studio { grid-template-columns: 1fr; }
  .marks-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .page { width: calc(100% - 1.5rem); }
  .mast { flex-direction: column; align-items: stretch; }
  .mast-tools { justify-content: flex-start; }
  .control-row, .final-actions, .marks-list { grid-template-columns: 1fr; }
  .glaze-grid, .brush-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .vessel-card, .sound-pill, .stage-btn, .chip-btn, .toggle-btn, .fire-btn { transition: none; }
  .vessel-card:hover { transform: none; }
}
