/* Cardwright studio — print-shop dark. */
:root {
  --bg: #14181d;
  --panel: #1b2128;
  --panel2: #20272f;
  --line: #2a323c;
  --text: #e6ebf0;
  --muted: #92a0af;
  --amber: #e8a33d;
  --amber-dim: #b57c25;
  --blue: #2f81f7;
  --green: #3fb96a;
  --red: #e05252;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 "CW-Inter", system-ui, sans-serif;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--amber-dim); }
input[type="number"] { width: 64px; }
input[type="color"] { padding: 1px 2px; width: 34px; height: 28px; cursor: pointer; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #333d49; border-radius: 6px; border: 2px solid var(--panel); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- frame ---------- */
#studio { display: grid; grid-template-rows: 50px 1fr; height: 100vh; }
#topbar {
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
#main { display: grid; grid-template-columns: 300px 1fr 330px; min-height: 0; }
.panel { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.panel:last-child { border-right: none; border-left: 1px solid var(--line); }
.panel h2 {
  margin: 0; padding: 10px 12px 8px; font-size: 11px; letter-spacing: 0.13em;
  color: var(--muted); text-transform: uppercase; display: flex; align-items: center; gap: 8px;
}
.panel h2 .spacer { flex: 1; }

/* ---------- topbar ---------- */
.brand { display: flex; align-items: baseline; gap: 2px; text-decoration: none; color: var(--text); margin-right: 6px; }
.brand b { font-family: "CW-PTSerif", Georgia, serif; font-size: 19px; font-weight: 700; }
.brand b em { color: var(--amber); font-style: normal; }
.brand .beta { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; margin-left: 4px; }
#projName { width: 210px; background: transparent; border-color: transparent; }
#projName:hover, #projName:focus { background: var(--panel2); border-color: var(--line); }
.btn {
  padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel2); white-space: nowrap;
}
.btn:hover { border-color: #3b4653; background: #242c35; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: #191203; font-weight: 600; }
.btn.primary:hover { background: #f0b155; }
.btn.small { padding: 3px 8px; font-size: 12.5px; }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.chip {
  font-size: 11.5px; padding: 3px 10px; border-radius: 20px; letter-spacing: 0.06em;
  border: 1px solid var(--line); color: var(--muted); font-weight: 600;
}
.chip.pro { border-color: var(--amber); color: var(--amber); }
.spacer { flex: 1; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 230px; z-index: 60;
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(0,0,0,0.5); padding: 6px; display: none;
}
.menu.open { display: block; }
.menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; }
.menu button:hover { background: #2a333e; }
.menu .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu .note { font-size: 11.5px; color: var(--muted); padding: 4px 10px 6px; }

/* ---------- data panel ---------- */
#dataTools { display: flex; gap: 6px; padding: 0 10px 8px; flex-wrap: wrap; }
#dataScroll { overflow: auto; flex: 1; }
table.data { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.data th, table.data td {
  border: 1px solid var(--line); padding: 4px 6px; min-width: 72px; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top;
}
table.data th {
  background: var(--panel2); position: sticky; top: 0; z-index: 2; font-weight: 600;
  color: var(--amber); cursor: text;
}
table.data th .colx { color: var(--muted); cursor: pointer; margin-left: 5px; font-weight: 400; }
table.data th .colx:hover { color: var(--red); }
table.data td { cursor: text; color: var(--text); }
table.data td:focus, table.data th:focus { outline: 1px solid var(--amber-dim); background: #232b34; white-space: normal; }
table.data tr.sel td { background: rgba(47,129,247,0.13); }
table.data td.rowno {
  color: var(--muted); min-width: 34px; text-align: right; cursor: pointer;
  background: var(--panel2); user-select: none;
}
table.data td.rowno:hover { color: var(--red); }

/* ---------- preview panel ---------- */
#previewPanel { background: #10141a; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#previewTools { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { padding: 5px 14px; background: var(--panel2); font-size: 12.5px; }
.seg button.on { background: var(--amber); color: #191203; font-weight: 600; }
#bigWrap { display: grid; place-items: center; padding: 18px; min-height: 0; flex: 1; overflow: auto; }
#bigCanvas { box-shadow: 0 8px 40px rgba(0,0,0,0.55); border-radius: 6px; background: #fff; cursor: default; }
#gridWrap { border-top: 1px solid var(--line); height: 190px; overflow-x: auto; overflow-y: hidden; display: flex; gap: 10px; padding: 12px; align-items: flex-start; flex-shrink: 0; }
.gridCard { text-align: center; cursor: pointer; flex-shrink: 0; }
.gridCard canvas { border-radius: 4px; box-shadow: 0 2px 10px rgba(0,0,0,0.4); display: block; }
.gridCard.sel canvas { outline: 2px solid var(--amber); }
.gridCard .cap { font-size: 10.5px; color: var(--muted); margin-top: 4px; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#zoomVal { font-size: 12px; color: var(--muted); width: 42px; text-align: center; }

/* ---------- design panel ---------- */
#designScroll { overflow-y: auto; flex: 1; padding-bottom: 30px; }
.group { border-bottom: 1px solid var(--line); padding: 10px 12px 12px; }
.group h3 { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.frow { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; flex-wrap: wrap; }
.frow label { font-size: 12.5px; color: var(--muted); min-width: 58px; }
.frow input[type="text"] { flex: 1; min-width: 60px; }
.frow textarea { width: 100%; min-height: 54px; resize: vertical; font-size: 13px; }
#elList { display: flex; flex-direction: column; gap: 4px; }
.elRow {
  display: flex; align-items: center; gap: 7px; padding: 6px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel2); cursor: pointer; font-size: 12.5px;
}
.elRow:hover { border-color: #3b4653; }
.elRow.sel { border-color: var(--amber); background: rgba(232,163,61,0.09); }
.elRow .tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em; padding: 2px 6px;
  border-radius: 4px; background: #2c3641; color: var(--muted); text-transform: uppercase;
}
.elRow .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.elRow .mini { color: var(--muted); padding: 2px 4px; border-radius: 4px; font-size: 12px; }
.elRow .mini:hover { color: var(--text); background: #2c3641; }
.addRow { display: flex; gap: 6px; margin-top: 8px; }
.hint { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.hint code { font-family: var(--mono); background: #242c35; border-radius: 4px; padding: 0 4px; font-size: 11px; }

/* ---------- modals ---------- */
#overlay {
  position: fixed; inset: 0; background: rgba(8,10,13,0.66); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
#overlay.open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  max-width: 720px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.modal header { display: flex; align-items: center; padding: 16px 20px 0; }
.modal header h2 { margin: 0; font-size: 18px; font-family: "CW-PTSerif", Georgia, serif; }
.modal .body { padding: 14px 20px 20px; }
.modal .x { margin-left: auto; color: var(--muted); font-size: 20px; padding: 2px 8px; border-radius: 6px; }
.modal .x:hover { background: var(--panel2); color: var(--text); }
.modeGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.modeCard {
  text-align: left; border: 1px solid var(--line); background: var(--panel2);
  border-radius: 10px; padding: 12px 14px;
}
.modeCard:hover { border-color: #45505d; }
.modeCard.on { border-color: var(--amber); background: rgba(232,163,61,0.07); }
.modeCard b { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.modeCard .desc { font-size: 12px; color: var(--muted); line-height: 1.45; }
.modeCard .pro { font-size: 10px; color: var(--amber); border: 1px solid var(--amber); padding: 1px 6px; border-radius: 10px; letter-spacing: 0.06em; }
.optRow { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 10px 0; }
.optRow label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.notice {
  border: 1px solid var(--line); border-left: 3px solid var(--amber); background: var(--panel2);
  border-radius: 6px; padding: 9px 12px; font-size: 12.5px; color: var(--muted); margin: 10px 0;
}
.notice b { color: var(--text); }
progress { width: 100%; height: 8px; accent-color: var(--amber); }
.calGrid { display: grid; grid-template-columns: repeat(5, 46px); gap: 5px; margin: 12px 0; }
.calGrid button {
  border: 1px solid var(--line); background: var(--panel2); border-radius: 6px;
  padding: 8px 0; font-family: var(--mono); font-size: 13px;
}
.calGrid button.on { background: var(--amber); color: #191203; border-color: var(--amber); font-weight: 700; }
.priceRow { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 2px; }
.priceRow .price { font-size: 34px; font-family: "CW-PTSerif", Georgia, serif; color: var(--amber); }
.priceRow .per { color: var(--muted); font-size: 13px; }
ul.feat { margin: 10px 0; padding-left: 20px; color: var(--text); font-size: 13.5px; line-height: 1.75; }
ul.feat li::marker { color: var(--amber); }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 16px; font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  animation: toastin 0.18s ease-out;
}
.toast.ok { border-left: 3px solid var(--green); }
.toast.err { border-left: 3px solid var(--red); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

/* ---------- import drawer ---------- */
#importArea { width: 100%; min-height: 150px; font-family: var(--mono); font-size: 12px; }

@media (max-width: 1100px) {
  #main { grid-template-columns: 250px 1fr 290px; }
}
