:root {
  color-scheme: light;
  --ink: #181818;
  --muted: #737373;
  --line: #dedbd5;
  --paper: #f5f3ee;
  --panel: #ffffff;
  --accent: #202020;
  font-family: Inter, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}

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

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
}

button, input { font: inherit; }

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 32px clamp(20px, 4vw, 64px) 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .72);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(26px, 3vw, 40px); letter-spacing: -.04em; }
.lead { margin-bottom: 0; color: var(--muted); font-size: 14px; }

.file-button, .save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 24px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
  cursor: pointer;
  transition: opacity .2s, transform .2s;
}

.file-button:hover, .save-button:not(:disabled):hover { opacity: .82; }
.file-button:active, .save-button:not(:disabled):active { transform: translateY(1px); }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  gap: 24px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px clamp(16px, 3vw, 48px) 48px;
}

.settings-panel, .preview-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.settings-panel { align-self: start; overflow: hidden; }
.file-status { padding: 18px 20px; border-bottom: 1px solid var(--line); background: #faf9f6; }
.file-status > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-text { margin-top: 5px; color: var(--muted); font-size: 12px; white-space: normal !important; }
.status-text.is-warning { color: #98610b; }
.status-text.is-success { color: #27734e; }

.setting-section { padding: 20px; border-bottom: 1px solid var(--line); }
.setting-section:last-child { border-bottom: 0; }
.setting-section h2, .preview-heading h2 { margin-bottom: 14px; font-size: 15px; letter-spacing: -.01em; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.section-heading span { color: var(--muted); font-size: 11px; }

.preset-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.preset-group label { position: relative; }
.preset-group input { position: absolute; opacity: 0; }
.preset-group span {
  display: block;
  padding: 9px 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  text-align: center;
  font-size: 13px;
  cursor: pointer;
}
.preset-group input:checked + span { border-color: var(--ink); color: #fff; background: var(--ink); }
.preset-group input:focus-visible + span { outline: 2px solid #4d90fe; outline-offset: 2px; }

.metadata-fields { display: grid; gap: 9px; }
.metadata-row { display: grid; grid-template-columns: 25px 112px minmax(0, 1fr); align-items: center; gap: 8px; }
.metadata-row > label { font-size: 12px; color: #4e4e4e; }
.metadata-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--ink); }
.metadata-row input[type="text"] {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
}
.metadata-row input[type="text"]:focus { border-color: #777; outline: 2px solid rgba(0,0,0,.08); }

.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.font-control { display: grid; grid-column: 1 / -1; gap: 7px; color: #4e4e4e; font-size: 12px; }
.font-control select {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink);
  background: #fff;
}
.range-control { display: grid; grid-template-columns: 1fr auto; gap: 7px; color: #4e4e4e; font-size: 12px; }
.range-control input { grid-column: 1 / -1; width: 100%; accent-color: var(--ink); }
.range-control output { color: var(--muted); }
.color-control { display: flex; align-items: center; justify-content: space-between; color: #4e4e4e; font-size: 12px; }
.color-control input { width: 44px; height: 30px; padding: 2px; border: 1px solid var(--line); background: #fff; cursor: pointer; }

.preview-panel { display: flex; min-height: 620px; padding: clamp(18px, 3vw, 32px); flex-direction: column; }
.preview-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.preview-heading h2 { margin-bottom: 0; font-size: 20px; }
.preview-heading > span { color: var(--muted); font-size: 12px; }

.canvas-stage {
  display: grid;
  flex: 1;
  min-height: 460px;
  place-items: center;
  padding: clamp(16px, 3vw, 40px);
  overflow: hidden;
  border: 1px solid #dedede;
  background-color: #ededed;
  background-image: linear-gradient(45deg, #e5e5e5 25%, transparent 25%), linear-gradient(-45deg, #e5e5e5 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e5e5e5 75%), linear-gradient(-45deg, transparent 75%, #e5e5e5 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.empty-preview { display: flex; align-items: center; padding: 32px; color: var(--muted); flex-direction: column; text-align: center; }
.empty-preview strong { margin: 14px 0 7px; color: #4d4d4d; font-size: 15px; }
.empty-preview span:last-child { font-size: 12px; }
.empty-mark { display: grid; width: 52px; height: 52px; place-items: center; border: 1px solid #aaa; border-radius: 50%; font-size: 24px; }
#previewCanvas { display: block; max-width: 100%; max-height: 72vh; box-shadow: 0 12px 35px rgba(0,0,0,.14); }
.save-button { width: 100%; margin-top: 18px; }
.save-button:disabled { border-color: #ccc; color: #888; background: #ddd; cursor: not-allowed; }

@media (max-width: 900px) {
  body { display: flex; flex-direction: column; }
  .app-header, .workspace { display: contents; }
  .app-header > div { display: none; }
  .preview-panel { order: 1; min-width: 0; min-height: auto; margin: 14px 12px 0; }
  .file-button { order: 2; width: auto; margin: 14px 12px 0; }
  .settings-panel { order: 3; min-width: 0; margin: 14px 12px 30px; }
  .canvas-stage { min-height: 380px; }
}

@media (max-width: 540px) {
  .app-header { align-items: stretch; padding: 22px 18px; flex-direction: column; }
  .file-button { width: auto; }
  .workspace { padding: 14px 12px 30px; }
  .settings-panel { display: flex; flex-direction: column; }
  .settings-panel .file-status { order: 1; }
  .settings-panel .setting-section:nth-of-type(1) { order: 2; }
  .settings-panel .setting-section:nth-of-type(3) { order: 3; }
  .settings-panel .setting-section:nth-of-type(2) { order: 4; }
  .setting-section { padding: 18px 15px; }
  .metadata-row { grid-template-columns: 23px 92px minmax(0, 1fr); gap: 6px; }
  .control-grid { grid-template-columns: 1fr; }
  .preview-panel { padding: 15px; }
  .canvas-stage { min-height: 300px; padding: 12px; }
  .preview-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
}
