:root {
  --ink: #262426;
  --muted: #8b8385;
  --line: #e7e1df;
  --surface: #fbfaf9;
  --panel: #ffffff;
  --paper: #f7f5f1;
  --accent: #ef6e51;
  --accent-dark: #d9573c;
  --soft-accent: #fff0eb;
  --grid: #d9d2cb;
  --shadow: 0 20px 48px rgba(50, 39, 35, .08);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #f4f1ef;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: #f4f1ef; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.license-gate { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: rgba(38, 36, 36, .42); backdrop-filter: blur(8px); }
.license-gate[hidden] { display: none; }
.license-panel { width: min(100%, 420px); padding: 34px; background: #fff; border: 1px solid rgba(255,255,255,.7); box-shadow: 0 24px 70px rgba(38, 36, 36, .22); }
.license-panel h1 { margin-top: 10px; font-size: 25px; }
.license-panel p { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.license-panel small { display: block; margin-top: 16px; color: #a69b96; font-size: 10px; line-height: 1.6; }
.license-input-wrap { display: block; margin-top: 22px; color: #61595a; font-size: 11px; font-weight: 700; }
.license-input-wrap input { display: block; width: 100%; margin-top: 8px; padding: 12px 13px; border: 1px solid var(--line); outline-color: var(--accent); color: var(--ink); font-size: 13px; letter-spacing: .08em; }
.license-submit { width: 100%; margin-top: 14px; }
.license-message { min-height: 18px; margin-bottom: -2px; color: var(--accent) !important; }
.license-badge { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border: 1px solid #f1c7bb; color: var(--accent); background: var(--soft-accent); font-size: 10px; font-weight: 700; }
.license-badge.active { border-color: #c8e6d2; color: #35855a; background: #eef9f1; }

.app-shell { min-height: 100vh; background: var(--surface); }
.topbar { height: 78px; padding: 0 42px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 29px; height: 29px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; transform: rotate(-8deg); }
.brand-mark i { background: var(--ink); display: block; border-radius: 2px; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(3) { background: var(--accent); }
.brand strong { font-size: 18px; letter-spacing: .02em; display: block; line-height: 1; }
.brand strong em { font-style: normal; font-size: 12px; color: var(--accent); margin-left: 4px; }
.brand small { display: block; margin-top: 6px; font-size: 8px; font-weight: 700; letter-spacing: .19em; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 20px; }
.secure-note { color: var(--muted); font-size: 12px; display: flex; gap: 7px; align-items: center; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #69b98b; box-shadow: 0 0 0 4px #e8f6ed; }
.ghost-button, .text-button { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 8px 4px; }
.ghost-button:hover, .text-button:hover { color: var(--ink); }
.primary-button, .secondary-button { border: 0; border-radius: 3px; min-height: 40px; padding: 0 17px; font-weight: 700; font-size: 12px; transition: transform .2s, background .2s; }
.primary-button { color: #fff; background: var(--accent); box-shadow: 0 8px 18px rgba(239,110,81,.2); }
.primary-button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.primary-button span { font-size: 17px; vertical-align: -1px; margin-right: 5px; }
.primary-button.compact { min-height: 38px; }

.workspace { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: calc(100vh - 78px); }
.sidebar { padding: 38px 30px 24px 42px; border-right: 1px solid var(--line); background: #fcfbfa; display: flex; flex-direction: column; }
.sidebar-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.eyebrow { margin: 0; color: var(--accent); font-size: 9px; letter-spacing: .17em; font-weight: 800; }
h1, h2, h3, p { margin: 0; }
h1 { margin-top: 8px; font-size: 27px; letter-spacing: -.04em; }
.step-badge { background: var(--ink); color: white; font-size: 10px; font-weight: 800; padding: 7px 8px; border-radius: 2px; letter-spacing: .08em; }
.intro-copy { font-size: 12px; line-height: 1.8; color: var(--muted); margin: 15px 18px 26px 0; }
.control-section { border-top: 1px solid var(--line); padding: 20px 0 18px; }
.section-label { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 800; margin-bottom: 14px; }
.section-index { color: #b3a9a5; font-size: 9px; letter-spacing: .09em; }
.upload-zone { min-height: 120px; padding: 18px; display: flex; align-items: center; flex-direction: column; justify-content: center; text-align: center; border: 1px dashed #cabfba; border-radius: 3px; background: #fff; transition: border .2s, background .2s, transform .2s; }
.upload-zone:hover, .upload-zone.dragging { border-color: var(--accent); background: var(--soft-accent); transform: translateY(-1px); }
.upload-zone input { display: none; }
.upload-icon { display: grid; place-items: center; width: 26px; height: 26px; margin-bottom: 9px; border: 1px solid #dbcfc9; border-radius: 50%; font-size: 19px; font-weight: 300; color: var(--accent); }
.upload-zone strong { font-size: 12px; }
.upload-zone small { color: var(--muted); font-size: 10px; margin-top: 6px; line-height: 1.5; }
.field-row { display: flex; align-items: center; justify-content: space-between; min-height: 36px; gap: 15px; }
.field-label { color: #61595a; font-size: 12px; }
.number-field { display: flex; align-items: center; border-bottom: 1px solid var(--ink); width: 105px; }
.number-field input { width: 75px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 15px; padding: 6px 0; }
.number-field span { color: var(--muted); font-size: 11px; }
select { width: 145px; border: 1px solid var(--line); border-radius: 2px; padding: 8px 9px; color: var(--ink); background: #fff; outline-color: var(--accent); font-size: 11px; }
.slider-row { margin-top: 5px; }
.range-wrap { width: 151px; display: flex; align-items: center; gap: 8px; }
input[type="range"] { appearance: none; width: 116px; height: 2px; background: #d7cfca; outline: none; }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--accent); }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--accent); }
output { min-width: 24px; text-align: right; font-size: 11px; color: var(--muted); }
.switch-row { display: flex; justify-content: space-between; align-items: center; color: #61595a; font-size: 12px; padding: 7px 0; }
.switch-input { display: none; }
.switch { position: relative; width: 30px; height: 17px; border-radius: 20px; background: #dfd8d4; transition: .2s; }
.switch::after { content: ""; position: absolute; left: 2px; top: 2px; width: 13px; height: 13px; border-radius: 50%; background: white; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.switch-input:checked + .switch { background: var(--accent); }
.switch-input:checked + .switch::after { transform: translateX(13px); }
.sidebar-footer { margin-top: auto; display: flex; gap: 10px; padding: 14px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.tip-mark { display: grid; place-items: center; flex: 0 0 17px; width: 17px; height: 17px; border: 1px solid #c8bbb5; border-radius: 50%; font-weight: 800; color: #9d918c; }
.sidebar-footer span { color: #a69b96; }

.main-panel { min-width: 0; padding: 35px 46px 26px; background: #f6f3f1; }
.panel-toolbar { display: flex; justify-content: space-between; align-items: end; margin-bottom: 27px; }
h2 { font-size: 23px; letter-spacing: -.04em; margin-top: 9px; }
h2 span { font-size: 12px; color: var(--muted); letter-spacing: 0; font-weight: 500; }
.toolbar-actions { display: flex; gap: 7px; }
.icon-button { width: 35px; height: 32px; border: 1px solid var(--line); border-radius: 2px; background: #fff; color: #a39793; font-size: 16px; transition: .2s; }
.icon-button.active, .icon-button:hover { color: var(--ink); border-color: #b9aaa3; background: #fff; }
.view-panel { display: none; animation: panelIn .28s ease both; }
.view-panel.active { display: block; }
@keyframes panelIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.result-summary { min-height: 82px; display: flex; justify-content: space-between; align-items: center; padding: 0 22px; background: #fff; border-bottom: 1px solid var(--line); }
.summary-main { display: flex; align-items: baseline; gap: 11px; }
.summary-kicker { display: block; font-size: 10px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.summary-main .summary-kicker { color: var(--accent); font-weight: 800; }
.summary-main strong { font-size: 20px; letter-spacing: -.04em; }
.summary-caption { color: var(--muted); font-size: 11px; }
.summary-stats { display: flex; gap: 30px; }
.summary-stats div { display: flex; flex-direction: column; gap: 4px; border-left: 1px solid var(--line); padding-left: 19px; }
.summary-stats strong { font-size: 15px; }
.summary-stats span { color: var(--muted); font-size: 10px; }
.paper-stage { background: var(--paper); margin-top: 15px; padding: 17px 22px 14px; box-shadow: var(--shadow); }
.paper-header, .paper-footer { display: flex; justify-content: space-between; font-size: 9px; font-weight: 700; color: #a39791; letter-spacing: .12em; }
.canvas-wrap { position: relative; display: grid; place-items: center; margin: 13px auto 12px; width: min(100%, 720px); aspect-ratio: 1; background: #fff; overflow: hidden; }
#patternCanvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.canvas-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 9px; background: rgba(255,255,255,.9); color: var(--muted); }
.canvas-empty.hidden,
.canvas-empty[hidden] { display: none; }
.canvas-empty strong { color: var(--ink); font-size: 13px; }
.canvas-empty small { font-size: 10px; }
.empty-swatch { width: 30px; height: 30px; background: conic-gradient(#e6ddd8 25%, #fff 0 50%, #e6ddd8 0 75%, #fff 0); background-size: 12px 12px; border: 1px solid #d9d0cb; }

.palette-heading { display: flex; justify-content: space-between; align-items: end; background: #fff; padding: 22px; }
.palette-heading h3 { margin-top: 8px; font-size: 19px; letter-spacing: -.03em; }
.text-button { color: var(--accent); font-weight: 700; }
.palette-table { background: #fff; margin-top: 1px; padding: 0 22px 20px; }
.palette-table-head, .palette-row { display: grid; grid-template-columns: 1.7fr 1fr 1fr 1fr; align-items: center; column-gap: 10px; }
.palette-table-head { min-height: 38px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.palette-row { min-height: 48px; border-bottom: 1px solid #f0ecea; font-size: 12px; }
.palette-color-name { display: flex; align-items: center; gap: 9px; }
.color-swatch { width: 18px; height: 18px; border-radius: 2px; border: 1px solid rgba(40,30,25,.11); }
.palette-row > span:not(.palette-color-name) { color: #6f6664; }
.bar-wrap { height: 4px; background: #f0ecea; }
.bar { height: 100%; background: var(--accent); }

.bottom-bar { display: flex; justify-content: space-between; align-items: center; padding: 21px 0 0; }
.source-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
.source-thumb { width: 41px; height: 41px; flex: 0 0 41px; display: grid; place-items: center; overflow: hidden; background: #e9e2df; color: #a69892; font-size: 8px; font-weight: 800; letter-spacing: .1em; }
.source-thumb img { width: 100%; height: 100%; object-fit: cover; }
.source-chip strong, .source-chip small { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-chip strong { font-size: 12px; }
.source-chip small { color: var(--muted); font-size: 10px; margin-top: 4px; }
.secondary-button { background: transparent; border: 1px solid #d2c8c3; color: #756b68; }
.secondary-button:hover { border-color: var(--accent); color: var(--accent); background: var(--soft-accent); }
.secondary-button span { color: var(--accent); margin-right: 5px; }
.hidden-canvas { display: none; }

@media (max-width: 930px) {
  .topbar { padding: 0 24px; }
  .workspace { grid-template-columns: 280px minmax(0, 1fr); }
  .sidebar { padding-left: 24px; padding-right: 22px; }
  .main-panel { padding: 28px 25px; }
  .summary-caption { display: none; }
  .summary-stats { gap: 15px; }
}
@media (max-width: 700px) {
  .topbar { height: 68px; padding: 0 16px; }
  .secure-note, .ghost-button { display: none; }
  .license-badge { font-size: 9px; }
  .workspace { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 24px 18px 18px; }
  .intro-copy { margin-bottom: 18px; }
  .control-section { padding: 15px 0; }
  .sidebar-footer { display: none; }
  .main-panel { padding: 23px 15px 20px; }
  .panel-toolbar { margin-bottom: 18px; align-items: center; }
  h2 { font-size: 19px; }
  .result-summary { padding: 0 14px; }
  .summary-main { gap: 7px; }
  .summary-main strong { font-size: 17px; }
  .summary-stats { gap: 10px; }
  .summary-stats div { padding-left: 10px; }
  .summary-stats strong { font-size: 13px; }
  .summary-stats span { font-size: 9px; }
  .paper-stage { padding: 13px 12px 11px; }
  .bottom-bar { align-items: flex-start; gap: 15px; }
  .secondary-button { white-space: nowrap; padding: 0 12px; }
  .license-panel { padding: 27px 22px; }
}
