/* ============================================================
   CoinForge Studio — app.css
   Dark workshop theme with a brass accent.
   Author: Hratch Simonyan · License: MIT
   ============================================================ */
:root {
  --bg: #15181d;
  --panel: #1d2128;
  --panel2: #232830;
  --line: #2e343d;
  --text: #dfe3e8;
  --muted: #8b93a0;
  --accent: #d9b544;
  --accent-dim: #8a6d1f;
  --blue: #5ec5ff;
  --danger: #e05b5b;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  user-select: none;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ============ top bar ============ */
#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 12px;
  background: linear-gradient(#22262e, #1b1f26);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.cf-brand { display: flex; align-items: baseline; gap: 5px; margin-right: 10px; }
.cf-brand-coin { font-size: 19px; }
.cf-brand-name { font-weight: 700; font-size: 16px; color: var(--accent); letter-spacing: 0.5px; }
.cf-brand-sub { font-size: 11px; color: var(--muted); letter-spacing: 2px; text-transform: uppercase; }
.cf-tb-group { display: flex; align-items: center; gap: 4px; }
.cf-tb-spacer { flex: 1; }
.cf-tbbtn {
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 11px;
  cursor: pointer;
  font-size: 13px;
}
.cf-tbbtn:hover { background: var(--panel2); border-color: var(--line); }
.cf-tbbtn:disabled { opacity: 0.35; cursor: default; }
.cf-tbbtn.cf-tb-primary {
  background: var(--accent);
  color: #201a08;
  font-weight: 600;
}
.cf-tbbtn.cf-tb-primary:hover { background: #e7c65e; }
.cf-zoomlbl { min-width: 46px; text-align: center; color: var(--muted); cursor: pointer; font-variant-numeric: tabular-nums; }
.cf-zoomlbl:hover { color: var(--text); }

/* ============ layout ============ */
#main { display: flex; flex: 1; min-height: 0; }
#left {
  width: 292px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
#right {
  width: 304px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 10px;
  flex-shrink: 0;
}
#canvas-wrap { flex: 1; position: relative; min-width: 0; }
#canvas-wrap.dropping::after {
  content: 'Drop image to import';
  position: absolute; inset: 12px;
  border: 2px dashed var(--accent);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--accent);
  background: rgba(20, 22, 28, 0.72);
  pointer-events: none;
}
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#statusbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 26px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 12px;
  background: rgba(20, 23, 29, 0.88);
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  backdrop-filter: blur(3px);
}
.cf-sb-right { margin-left: auto; }
.cf-sb-item.dirty { color: var(--accent); }

/* ============ left panel tabs ============ */
.cf-tabbar { display: flex; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.cf-tab {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 9px 2px;
  font-size: 12px;
  cursor: pointer;
}
.cf-tab:hover { color: var(--text); }
.cf-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.cf-panehost { flex: 1; overflow-y: auto; }
.cf-pane { padding: 10px; }
.cf-pane-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--muted); margin: 12px 0 8px;
}
.cf-pane-title:first-child { margin-top: 2px; }
.cf-subhead { font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; margin: 10px 0 2px; }

/* add grid */
.cf-addgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.cf-addbtn {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 10px;
  cursor: pointer;
  font-size: 12.5px;
  text-align: left;
}
.cf-addbtn:hover { border-color: var(--accent-dim); background: #2a3039; }
.cf-addicon {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  background: #171a20;
  border-radius: 6px;
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* symbol grids */
.cf-symgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 6px; margin-top: 10px; max-height: 52vh; overflow-y: auto; }
.cf-symgrid-narrow { max-height: none; overflow: visible; }
.cf-symcell {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 3px 5px;
  cursor: pointer;
}
.cf-symcell:hover { border-color: var(--accent); }
.cf-symcell span { font-size: 9.5px; color: var(--muted); text-align: center; line-height: 1.15; max-width: 100%; overflow: hidden; }
.cf-symcell canvas { border-radius: 4px; }
.cf-glyph-thumb {
  display: flex; align-items: center; justify-content: center;
  font-family: "Segoe UI Symbol", "Segoe UI", serif;
  font-size: 26px;
  color: #e8e2d0;
}
.cf-chipbar { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.cf-chip {
  background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 20px; padding: 4px 11px; font-size: 11.5px; cursor: pointer;
}
.cf-chip.active { color: #201a08; background: var(--accent); border-color: var(--accent); }

/* cards (rings / templates) */
.cf-cardlist { display: flex; flex-direction: column; gap: 8px; }
.cf-card {
  display: flex; gap: 9px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px;
  cursor: pointer;
  align-items: center;
}
.cf-card:hover { border-color: var(--accent-dim); }
.cf-card canvas { width: 74px; height: 74px; border-radius: 6px; flex-shrink: 0; }
.cf-card-title { font-weight: 600; font-size: 12.5px; }
.cf-card-desc { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.3; }

/* layers */
.cf-layerlist { display: flex; flex-direction: column; gap: 3px; }
.cf-layer {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 7px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
}
.cf-layer:hover { background: var(--panel2); }
.cf-layer.selected { background: #2a3341; border-color: #3b4d63; }
.cf-layer.hidden-el .cf-layer-name { opacity: 0.4; }
.cf-layer.dragover { border-top: 2px solid var(--accent); }
.cf-layer-icon {
  width: 20px; height: 20px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: #171a20; border-radius: 5px;
  color: var(--accent); font-size: 11px; font-weight: 700;
}
.cf-layer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.cf-layer-btn { background: none; border: none; cursor: pointer; font-size: 12px; opacity: 0.75; color: var(--text); }
.cf-layer-btn:hover { opacity: 1; }

/* ============ fields ============ */
.cf-section {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 10px;
}
.cf-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--accent); margin-bottom: 9px; font-weight: 600;
}
.cf-field { margin-bottom: 8px; }
.cf-field-label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.cf-input {
  width: 100%;
  background: #14171c;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12.5px;
  font-family: inherit;
}
.cf-input:focus { outline: none; border-color: var(--accent-dim); }
.cf-textarea { resize: vertical; min-height: 44px; }
.cf-num-wrap { display: flex; align-items: center; gap: 6px; }
.cf-num-wrap .cf-input { flex: 1; }
.cf-unit { color: var(--muted); font-size: 11px; flex-shrink: 0; }
.cf-unit-sel { width: 62px; flex-shrink: 0; }
.cf-slider-wrap { display: flex; align-items: center; gap: 8px; }
.cf-slider { flex: 1; accent-color: var(--accent); }
.cf-slider-val { min-width: 34px; text-align: right; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cf-field-check { display: flex; flex-direction: column; gap: 5px; }
.cf-check-label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; cursor: pointer; }
.cf-check-label input { accent-color: var(--accent); }
.cf-hint { font-size: 11.5px; color: var(--muted); line-height: 1.45; margin: 8px 0; user-select: text; }

.cf-btn {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
}
.cf-btn:hover { border-color: var(--accent-dim); }
.cf-btn.primary { background: var(--accent); border-color: var(--accent); color: #201a08; font-weight: 600; }
.cf-btn.primary:hover { background: #e7c65e; }
.cf-btn.danger { color: #ff9c9c; border-color: #5a3030; }
.cf-btn.danger:hover { background: #3a2323; }
.cf-btn:disabled { opacity: 0.4; cursor: default; }
.cf-btn-sm { padding: 5px 9px; font-size: 11.5px; }
.cf-btn-block { display: block; width: 100%; margin-bottom: 6px; text-align: left; }
.cf-btn-row { display: flex; gap: 6px; margin-bottom: 6px; }
.cf-btn-row .cf-btn { flex: 1; }
.cf-btn-row.cf-wrap { flex-wrap: wrap; }
.cf-btn-row.cf-wrap .cf-btn { flex: 0 1 auto; }
.cf-btn-col { display: flex; flex-direction: column; }

/* ============ modal ============ */
.cf-overlay {
  position: fixed; inset: 0;
  background: rgba(8, 10, 13, 0.68);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.cf-modal {
  background: var(--panel);
  border: 1px solid #363d48;
  border-radius: 12px;
  width: 560px;
  max-width: 96vw;
  max-height: 92vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.cf-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.cf-modal-title { font-weight: 600; font-size: 14.5px; color: var(--accent); }
.cf-modal-x {
  background: none; border: none; color: var(--muted);
  font-size: 22px; cursor: pointer; line-height: 1;
}
.cf-modal-x:hover { color: var(--text); }
.cf-modal-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
.cf-modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.cf-foot-spread { display: flex; gap: 8px; width: 100%; justify-content: flex-end; }
.cf-confirm-msg { line-height: 1.5; user-select: text; }

/* menu */
.cf-menu {
  position: fixed;
  background: var(--panel2);
  border: 1px solid #3a4149;
  border-radius: 9px;
  padding: 5px;
  min-width: 230px;
  z-index: 200;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
}
.cf-menu-item {
  display: flex; justify-content: space-between; align-items: center; gap: 18px;
  padding: 7px 11px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
}
.cf-menu-item:hover { background: #313845; }
.cf-menu-item.disabled { opacity: 0.4; cursor: default; }
.cf-menu-hint { color: var(--muted); font-size: 11px; }
.cf-menu-sep { height: 1px; background: var(--line); margin: 5px 8px; }

/* toast */
#cf-toasts {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 300;
  pointer-events: none;
}
.cf-toast {
  background: #2b313b;
  border: 1px solid #3d4653;
  color: var(--text);
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 12.5px;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s ease;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
}
.cf-toast.show { opacity: 1; transform: none; }
.cf-toast.error { border-color: #6c3a3a; color: #ffb4b4; }

/* inline text editor over canvas */
.cf-inline-edit {
  position: fixed;
  z-index: 150;
  width: 230px;
  background: #14171c;
  color: var(--text);
  border: 1.5px solid var(--accent);
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* ============ export dialog ============ */
.cf-export-grid { display: grid; grid-template-columns: 1fr 360px; gap: 18px; }
.cf-export-preview { width: 340px; height: 340px; border-radius: 8px; border: 1px solid var(--line); }
@media (max-width: 900px) { .cf-export-grid { grid-template-columns: 1fr; } }

/* ============ bg studio ============ */
.cf-bg-wrap { display: grid; grid-template-columns: 250px 1fr; gap: 16px; }
.cf-bg-tools { display: flex; flex-direction: column; }
.cf-bg-canvashost {
  display: flex; align-items: center; justify-content: center;
  background: #14171c;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 480px;
}
.cf-bg-view { border-radius: 6px; max-width: 100%; }

/* ============ projects ============ */
.cf-projgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.cf-projcard {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  cursor: pointer;
}
.cf-projcard:hover { border-color: var(--accent-dim); }
.cf-proj-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 7px; background: #14171c; }

/* ============ help ============ */
.cf-help-wrap { display: grid; grid-template-columns: 210px 1fr; gap: 0; min-height: 60vh; }
.cf-help-nav { border-right: 1px solid var(--line); padding-right: 10px; }
.cf-help-link {
  padding: 8px 10px; border-radius: 7px; cursor: pointer;
  font-size: 12.5px; color: var(--muted); margin-bottom: 2px;
}
.cf-help-link:hover { color: var(--text); background: var(--panel2); }
.cf-help-link.active { color: var(--accent); background: var(--panel2); font-weight: 600; }
.cf-help-about { margin-top: 18px; padding: 10px; font-size: 11px; color: var(--muted); }
.cf-help-body {
  padding: 4px 6px 20px 20px;
  overflow-y: auto;
  max-height: 74vh;
  user-select: text;
  line-height: 1.6;
  font-size: 13px;
}
.cf-help-body h1 { color: var(--accent); font-size: 21px; margin: 12px 0 10px; }
.cf-help-body h2 { color: var(--accent); font-size: 16px; margin: 18px 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.cf-help-body h3 { font-size: 14px; margin: 14px 0 6px; }
.cf-help-body h4 { font-size: 13px; margin: 12px 0 4px; color: var(--muted); }
.cf-help-body p { margin: 7px 0; }
.cf-help-body ul, .cf-help-body ol { margin: 7px 0 7px 22px; }
.cf-help-body li { margin: 3px 0; }
.cf-help-body code {
  background: #14171c; border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px; font-family: Consolas, monospace; font-size: 12px;
}
.cf-help-body pre {
  background: #14171c; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 8px 0;
}
.cf-help-body pre code { border: none; background: none; padding: 0; }
.cf-help-body table { border-collapse: collapse; margin: 10px 0; width: 100%; }
.cf-help-body th, .cf-help-body td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; font-size: 12.5px; }
.cf-help-body th { background: var(--panel2); color: var(--accent); }
.cf-help-body blockquote {
  border-left: 3px solid var(--accent-dim);
  padding: 4px 12px; margin: 8px 0; color: var(--muted);
  background: rgba(217, 181, 68, 0.05);
}
.cf-help-body a { color: var(--blue); }
.cf-help-body hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

/* about */
.cf-about { text-align: center; padding: 10px 0 4px; }
.cf-about-logo { font-size: 46px; margin-bottom: 8px; }
.cf-about h2 { color: var(--accent); margin-bottom: 6px; }
.cf-about p { margin: 4px 0; }

/* layer groups */
.cf-grouphead {
  display: flex; align-items: center; gap: 7px;
  margin-top: 7px;
  padding: 5px 7px;
  border-radius: 6px;
  background: #191d24;
  border: 1px solid var(--line);
}
.cf-grouphead.solo { border-color: var(--accent); }
.cf-grouphead.dragover { border-color: var(--accent); background: #262c36; }
.cf-grouphead-plain { background: transparent; border-color: transparent; }
.cf-groupdot {
  width: 12px; height: 12px; border-radius: 3px;
  flex-shrink: 0; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.cf-groupname {
  flex: 1;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333a44; border-radius: 6px; border: 2px solid var(--panel); }
::-webkit-scrollbar-thumb:hover { background: #414a56; }