:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  background: #171815;
  color: #f5f3e9;
  --muted: #b9baae;
  --line: #484b3f;
  --panel: #22241e;
  --accent: #d6fa7d;
  --violet: #d9ceff;
  --coral: #ffae99;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; line-height: 1.6; }
button, input { font: inherit; }
button, a { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.shell { width: min(1100px, calc(100% - 48px)); margin: 0 auto; padding: 52px 0 48px; }
.locale-bar { display: flex; justify-content: flex-end; margin-block-end: 1rem; }
.locale-menu { position: relative; z-index: 2; }
.locale-menu summary { cursor: pointer; border: 1px solid var(--line); border-radius: 8px; padding: .4rem .75rem; }
.locale-menu nav { position: absolute; inset-inline-end: 0; min-inline-size: 12rem; max-block-size: 60vh; overflow: auto; margin-block-start: .35rem; border: 1px solid var(--line); border-radius: 8px; background: #242520; box-shadow: 0 8px 24px #0007; }
.locale-menu ul { list-style: none; margin: 0; padding: .3rem; }
.locale-menu a { display: block; border-radius: 4px; color: inherit; padding: .35rem .6rem; }
.locale-menu a[aria-current='page'] { color: var(--accent); font-weight: 700; }
.locale-menu a:hover { background: #ffffff16; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font: 700 .76rem/1.4 ui-monospace, monospace;
  letter-spacing: .23em;
}
h1 { margin: 0; font-size: clamp(2rem, 6vw, 4rem); line-height: 1.14; letter-spacing: -.055em; }
h1 span { color: var(--accent); }
.intro { margin: 14px 0 0; color: var(--muted); }
.hero-mark { display: grid; grid-template-columns: repeat(2, 30px); gap: 5px; padding: 8px; flex: none; }
.hero-mark i { aspect-ratio: 1; background: var(--accent); border-radius: 3px 50% 3px 3px; }
.hero-mark i:nth-child(2) { background: var(--violet); transform: rotate(90deg); }
.hero-mark i:nth-child(3) { background: var(--coral); transform: rotate(-90deg); }
.hero-mark i:nth-child(4) { border: 1px solid var(--line); background: transparent; transform: rotate(180deg); }
.privacy { display: flex; align-items: baseline; gap: 9px; color: var(--muted); margin: 22px 0; font-size: .85rem; }
.privacy span { background: var(--accent); border-radius: 50%; width: 7px; height: 7px; flex: none; }

.workspace { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.panel, .settings { background: var(--panel); border: 1px solid var(--line); border-radius: 15px; padding: 16px; }
.panel-result { border-color: #73835b; }
.panel-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; }
.panel-heading h2 { margin: 0; font-size: 1rem; line-height: 1.4; }
.panel-heading p { margin: 2px 0 0; color: var(--muted); font-size: .75rem; }
.badge { display: grid; place-items: center; width: 37px; aspect-ratio: 1; border-radius: 8px; flex: none; color: #171815; font: 750 1.1rem/1 ui-monospace, monospace; }
.badge-a { background: var(--violet); }
.badge-b { background: var(--coral); }
.badge-result { background: var(--accent); }
.preview {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  aspect-ratio: 4/3;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid #414437;
  background: #1a1b17;
}
.preview.has-image {
  background: conic-gradient(#2a2c24 25%, #1a1b17 0 50%, #2a2c24 0 75%, #1a1b17 0) 0 0 / 16px 16px;
}
.preview canvas { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; }
.placeholder { margin: 0; padding: 12px; text-align: center; color: var(--muted); font-size: .82rem; }
.file-picker, .download, button {
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
  font-size: .87rem;
  min-height: 43px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}
.file-picker, .download { position: relative; width: 100%; margin-top: 12px; color: inherit; background: #292c23; }
.file-picker:hover, .download:hover, .secondary:hover { background: #383d2e; }
.file-picker:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.file-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-info { margin: 8px 0 0; color: var(--muted); font-size: .76rem; overflow-wrap: anywhere; }
.download { border-color: #73835b; color: var(--accent); }

.settings { display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 12px 18px; margin-top: 14px; }
.tile-setting label { display: block; font-weight: 700; font-size: .87rem; margin-bottom: 5px; }
.number-field { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: #171815; min-height: 43px; padding-inline-end: 10px; color: var(--muted); }
.number-field:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.number-field input { width: 88px; padding: 7px 10px; color: #f5f3e9; background: transparent; border: 0; outline: none; }
.number-field span { font: .82rem ui-monospace, monospace; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.primary { color: #171815; background: var(--accent); border-color: var(--accent); }
.primary:hover:not(:disabled) { background: #e4ffab; }
.primary:disabled { opacity: .55; cursor: not-allowed; }
.secondary { color: inherit; background: #292c23; }
.help, .notice, .status { grid-column: 1/-1; margin: 0; font-size: .85rem; }
.help { color: var(--muted); }
.notice { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: #1a1b17; }
.is-error { color: #ffc0af; }

@media (max-width: 720px) {
  .shell { width: min(100% - 32px, 520px); padding-top: 32px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 390px) {
  .hero-mark { display: none; }
  .settings { column-gap: 10px; }
}
