:root {
  --ink: #1f1d1b;
  --red: #e5452b;
  --line: #e7e2dc;
  --cream: #f8f6f2;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  line-height: 1.75;
  background: #fff;
}
button,
input,
textarea,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid #f3a393;
  outline-offset: 2px;
}
header {
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.top,
nav,
main,
footer {
  width: min(1120px, calc(100% - 48px));
  margin: auto;
}
.top {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-weight: 900;
  color: var(--ink);
  text-decoration: none;
  font-size: 18px;
}
.brand span {
  font-size: 12px;
  letter-spacing: 0.13em;
  color: var(--red);
}
.tag,
.sample {
  font-size: 12px;
  color: #746c65;
}
.tag {
  border: 1px solid var(--line);
  padding: 3px 10px;
  border-radius: 20px;
}
nav {
  display: flex;
  gap: 32px;
  overflow: auto;
}
nav button {
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 12px 0;
  white-space: nowrap;
  color: #6e6862;
  font-weight: 700;
  min-height: 48px;
}
nav button.active {
  color: var(--ink);
  border-color: var(--red);
}
main {
  padding: 50px 0 80px;
}
.intro {
  margin-bottom: 36px;
}
.intro h1 {
  font-size: clamp(28px, 3vw, 40px);
  letter-spacing: 0.02em;
  line-height: 1.35;
  margin: 5px 0 12px;
}
.intro p {
  margin: 0;
  color: #716a64;
}
.eyebrow {
  font-size: 12px !important;
  letter-spacing: 0.15em;
  color: var(--red) !important;
  font-weight: 800;
}
.compact {
  margin-bottom: 30px;
}
.layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
  gap: 28px;
  align-items: start;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  background: #fff;
  box-shadow: 0 6px 24px #35251508;
}
.panel h2,
.preview-wrap h2 {
  font-size: 19px;
  margin: 0;
}
.panel h3 {
  font-size: 15px;
}
.muted,
.small {
  color: #746d67;
}
.small {
  font-size: 12px;
}
.panel p {
  margin-top: 8px;
}
.primary,
.secondary,
.file-button {
  min-height: 46px;
  border-radius: 7px;
  padding: 10px 18px;
  font-weight: 700;
}
.primary {
  background: var(--red);
  border: 1px solid var(--red);
  color: #fff;
}
.primary span {
  float: right;
}
.secondary,
.file-button {
  background: #fff;
  border: 1px solid #cfc7bf;
  color: var(--ink);
}
.wide {
  width: 100%;
}
.text-button {
  border: 0;
  background: transparent;
  color: var(--red);
  font-weight: 700;
  min-height: 44px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.section-head .eyebrow {
  margin: 0;
}
.hint {
  padding: 24px 6px;
  color: #756e67;
  font-size: 13px;
}
.hint p {
  margin: 4px 0;
}
details {
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 16px;
}
summary {
  cursor: pointer;
  font-weight: 700;
}
label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin: 16px 0 6px;
}
input,
textarea,
select {
  display: block;
  width: 100%;
  border: 1px solid #ccc4bc;
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 6px;
  color: var(--ink);
  font-size: 16px;
  background: #fff;
}
textarea {
  resize: vertical;
  line-height: 1.6;
}
.result-item {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.result-item .label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.result-item h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #83786f;
}
.result-item p {
  white-space: pre-wrap;
  margin: 6px 0 0;
  font-size: 15px;
}
.result-item.title p {
  font-size: 23px;
  font-weight: 800;
}
.lock {
  background: none;
  border: 0;
  color: #a49a92;
  font-size: 12px;
  min-height: 36px;
}
.lock.locked {
  color: var(--red);
  font-weight: 700;
}
.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}
.actions button {
  flex: 1 1 max-content;
}
.result .actions button {
  white-space: nowrap;
}
.divider {
  border-top: 1px solid var(--line);
  padding-top: 22px;
  margin-top: 24px;
}
.field-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.field-head button {
  border: 0;
  background: none;
  color: #777;
  font-size: 12px;
  min-height: 36px;
}
.field-count {
  font-size: 12px;
  color: #8d857e;
  text-align: right;
}
.work {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-left: 3px solid transparent;
  background: #fff;
  padding: 12px;
  margin: 8px 0;
  min-height: 48px;
}
.work.active {
  border-color: var(--red);
  background: #f9f4f0;
  font-weight: 700;
}
.small-panel {
  margin-top: 16px;
}
.small-panel h2 {
  font-size: 15px;
}
.file-button {
  display: block;
  text-align: center;
  margin-top: 10px;
  cursor: pointer;
}
.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.optional {
  font-weight: 400;
  color: #8b827a;
}
.preview-wrap {
  padding: 0 18px;
}
.preview-wrap > .section-head {
  margin-bottom: 14px;
}
.card {
  max-width: 440px;
  margin: auto;
  background: #faf6ef;
  box-shadow: 0 8px 30px #31251b20;
}
.card-cover {
  min-height: 300px;
  background: linear-gradient(145deg, #384a49, #182d32);
  color: white;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: end;
}
.cover-content {
  padding: 32px;
  background: linear-gradient(transparent, #122329dc);
  width: 100%;
}
.cover-kicker,
.card-body span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
}
.cover-kicker {
  color: #f3bb9c;
}
.card-cover h2 {
  font-size: 28px;
  line-height: 1.4;
  margin: 12px 0;
}
.card-cover p {
  font-size: 13px;
  margin: 0;
}
.card-body {
  padding: 25px 32px;
}
.card-body > div {
  border-bottom: 1px solid #e5d9cc;
  padding: 12px 0;
}
.card-body span {
  color: #b25f49;
}
.card-body p {
  font-size: 13px;
  margin: 5px 0;
}
.swatches {
  display: flex;
  gap: 6px;
  margin: 8px 0;
}
.swatches i {
  width: 22px;
  height: 22px;
  background: #293c3b;
  border-radius: 50%;
}
.swatches i:nth-child(2) {
  background: #be825f;
}
.swatches i:nth-child(3) {
  background: #e5d2b9;
}
.card-url {
  overflow-wrap: anywhere;
  color: #756e67;
}
footer {
  border-top: 1px solid var(--line);
  padding: 25px 0;
  font-size: 12px;
  color: #8a817a;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .top,
  nav,
  main,
  footer {
    width: calc(100% - 32px);
  }
  .top {
    height: 62px;
  }
  nav {
    gap: 22px;
  }
  nav button {
    font-size: 13px;
  }
  main {
    padding: 32px 0 55px;
  }
  .layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  .panel {
    padding: 20px;
  }
  .intro {
    margin-bottom: 25px;
  }
  .intro h1 {
    font-size: 28px;
  }
  .hint {
    padding: 15px 4px 0;
  }
  .preview-wrap {
    padding: 4px 0;
  }
  .card-cover {
    min-height: 260px;
  }
  .card-cover h2 {
    font-size: 24px;
  }
  .actions button {
    flex: 1 1 auto;
  }
}

canvas.card {
  display: block;
  width: 100%;
  height: auto;
}

fieldset { border: 0; padding: 0; margin: 16px 0; }
legend { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { border: 1px solid #d7c9be; border-radius: 20px; background: #fff; padding: 7px 12px; color: #493b35; cursor: pointer; }
.chip.chosen { background: #344c49; color: white; border-color: #344c49; }
.result-tags { color: #855443; font-size: 13px; }
.start-card { background: #f8eee7; padding: 16px; border-radius: 12px; margin: 16px 0; line-height: 1.7; }
.start-card p { margin: 6px 0 0; }
.shuffling { opacity: .45; transition: opacity .2s; }
#skip { margin-top: 8px; }
@media (prefers-reduced-motion: reduce) { .shuffling { transition: none; } }

.result-item p { white-space: pre-line; }
.option-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin:16px 0; }
.select-field { display:flex; flex-direction:column; gap:6px; margin:0; font-size:14px; font-weight:700; min-width:0; }
.select-field select { width:100%; min-height:44px; padding:8px; border:1px solid #c7c2ba; border-radius:6px; background:white; color:#222; font:inherit; font-size:16px; margin-top:auto; }
.preset-row, .result-mode { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin:16px 0; }
.preset-row button, .result-mode button { min-height:44px; padding:8px 12px; border:1px solid #ccc; background:white; border-radius:6px; }
.result-mode .active { background:#a73527; color:white; border-color:#a73527; }
.private-result { border-left:3px solid #a73527; padding-left:12px; }
.result-item p { white-space:pre-wrap; overflow-wrap:anywhere; }
@media (max-width:375px) { .option-grid { grid-template-columns:1fr 1fr; } }
.result-controls { display:flex; flex-wrap:wrap; gap:6px; }
.result-controls button { min-height:44px; }
.character-detail { border-left:3px solid #c4b9ac; padding-left:12px; }
.result-item .label-row { flex-wrap:wrap; }
#manualCopyLabel[hidden] { display:none; }
@media (max-width: 375px) { .intro h1 { font-size:24px; } }
:root { --red: #c93a22; }
.lock { color: #675e57; }
#advancedOptions { display:block; }
.condition-group h3 { margin: 18px 0 0; }
.condition-group .option-grid { margin-top: 8px; }
[aria-invalid="true"] { border: 2px solid #b42519 !important; }
.condition-error { color:#922316; font-size:14px; margin:8px 0; }
.condition-error button { min-height:44px; }
.result-toolbar { position:sticky; top:0; z-index:2; display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:10px 0; background:#fff; }
.more-controls { margin:0; padding:0; border:0; }
.more-controls summary { cursor:pointer; min-height:44px; padding:8px; color:#675e57; }
.mobile-bar { display:none; }
[hidden] { display:none !important; }
@media (max-width:700px) {
  body:has(#gacha:not([hidden])) main { padding-bottom: calc(125px + env(safe-area-inset-bottom)); }
  #draw { display:none; }
  .mobile-bar { position:fixed; z-index:5; bottom:0; left:0; right:0; display:flex; gap:8px; padding:8px 16px calc(8px + env(safe-area-inset-bottom)); background:#fff; box-shadow:0 -2px 12px #0002; }
  .mobile-bar button { flex:1; }
  .result-toolbar { position:static; }
  body:has(input:focus, textarea:focus) .mobile-bar { display:none; }
}

.ui-icon { display:inline-block; width:18px; height:18px; flex:none; vertical-align:middle; }
.chip { display:inline-flex; align-items:center; gap:6px; min-height:44px; }
.result-empty { margin:0; padding:44px 12px; color:#675e57; text-align:center; }
.result-title h2 { font-size:clamp(23px, 2.2vw, 30px); line-height:1.4; overflow-wrap:anywhere; }
.result-title .label-row, .result-item .label-row { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.result-tag-row { display:flex; align-items:center; flex-wrap:wrap; gap:4px 8px; margin:12px 0 20px; }
.result-tags { display:flex; flex:1 1 180px; flex-wrap:wrap; gap:7px; margin:0; }
.result-tag { display:inline-flex; align-items:center; gap:5px; padding:4px 9px; background:#faf0eb; border-radius:18px; color:#733a2c; font-size:13px; font-weight:700; }
.result-tag .ui-icon { width:15px; height:15px; }
.result-controls { flex:none; }
.icon-control { display:inline-flex; align-items:center; justify-content:center; width:44px; height:44px; padding:0; border:1px solid transparent; border-radius:8px; color:#675e57; background:transparent; }
.icon-control.locked { color:#a12c1a; background:#faeae5; border-color:#c93a22; }
.character-cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr)); gap:10px; }
.character-card { padding:14px; background:#faf6f2; border-radius:9px; min-width:0; }
.character-card h4 { margin:0; }
.character-card h4 span { font-size:13px; font-weight:400; color:#675e57; }
.character-traits { display:flex; flex-wrap:wrap; gap:6px; padding:0; margin:10px 0; list-style:none; }
.character-traits li { padding:3px 10px; border:1px solid #d8ada1; border-radius:5px; background:#fff; color:#8b2b1c; font-size:14px; font-weight:800; line-height:1.6; }
.character-card p { margin:6px 0 0; }
.character-voice { color:#675e57; font-size:13px; line-height:1.8; overflow-wrap:anywhere; }
.result-toolbar { position:static; }
@media (max-width:700px) { .result-title .label-row { align-items:flex-start; } }

.character-card .character-reading { margin-top:3px; color:#675e57; font-size:12px; overflow-wrap:anywhere; }
.character-card .character-role { font-size:13px; color:#675e57; }
.character-card .character-stats { font-size:13px; font-weight:700; }
.character-card h4 { overflow-wrap:anywhere; }

.character-appearance { margin:12px 0; font-size:13px; line-height:1.7; }
.character-appearance div { display:grid; grid-template-columns:2.5em minmax(0,1fr); gap:6px; margin:3px 0; }
.character-appearance dt { color:#756960; font-weight:600; }
.character-appearance dd { margin:0; overflow-wrap:anywhere; }
.character-appearance-legacy { color:#675e57; font-size:13px; }

@media (max-width:900px) { .editor-layout > aside { order:2; } .editor-layout > .panel { order:1; } }
@media (max-width:700px) { #saveGacha { display:none; } }
.preset-row button { border-radius:20px; border-color:#d7c9be; color:#493b35; }
