/* GraphoriDraw editor styles. White and light grays; brand colors used sparingly. */

:root {
  --ink: #111111;
  --ink-2: #33383e;
  --muted: #6b7178;
  --border: #e6e7ea;
  --panel: #f6f7f8;
  --stage: #eceef1;
  --white: #ffffff;
  --yellow: #EEB143;
  --blue: #4889DF;
  --pink: #E13C88;
  --green: #54C054;
  --blue-soft: rgba(72, 137, 223, 0.14);
  --shadow-sm: 0 1px 2px rgba(17, 17, 17, 0.06);
  --shadow: 0 1px 2px rgba(17, 17, 17, 0.05), 0 6px 20px rgba(17, 17, 17, 0.07);
  --shadow-lg: 0 12px 40px rgba(17, 17, 17, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
kbd { font: inherit; }

/* ---------- Icons ---------- */
.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg {
  width: 100%; height: 100%;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--white); cursor: pointer;
  font-weight: 550; white-space: nowrap;
  transition: background-color .12s, border-color .12s;
}
.btn:hover { background: var(--panel); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--white); }
.btn-primary:hover { background: #2b2f34; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--panel); }
.btn-small { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-danger:hover:not(:disabled) { color: var(--pink); border-color: rgba(225, 60, 136, .35); background: rgba(225, 60, 136, .05); }

.tool-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--ink-2);
  cursor: pointer;
  transition: background-color .12s, color .12s;
}
.tool-btn:hover { background: var(--white); }
.tool-btn[aria-pressed="true"] {
  background: var(--white); color: var(--blue);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}
.tool-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.tool-btn.small { width: 32px; height: 32px; border-radius: 8px; }
.tool-btn.small:hover { background: var(--panel); }

.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--panel); border-radius: 10px;
}
.segmented button {
  min-width: 36px; height: 28px; padding: 0 9px;
  border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font-size: 12.5px; font-weight: 650;
  cursor: pointer;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--white); color: var(--ink); box-shadow: var(--shadow-sm); }
.segmented.wide { display: flex; }
.segmented.wide button { flex: 1; height: 32px; }

.select, .input {
  height: 32px; padding: 0 9px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--white); outline: none;
}
.select:focus, .input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.input-num { width: 84px; }

/* ---------- Header ---------- */
.app-header {
  flex: none;
  display: flex; align-items: center; gap: 16px;
  height: 62px; padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.brand-symbol { width: 28px; height: 28px; display: block; }
.brand-logo { height: 28px; width: auto; display: block; }
.brand-text { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.brand-link { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-site { display: block; flex: none; }
.brand-site .brand-symbol { transition: transform .4s ease; }
.brand-site:hover .brand-symbol { transform: rotate(-25deg); }
.beta-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 7px; line-height: 1; }
.brand-draw span:nth-child(1) { color: var(--yellow); }
.brand-draw span:nth-child(2) { color: var(--blue); }
.brand-draw span:nth-child(3) { color: var(--pink); }
.brand-draw span:nth-child(4) { color: var(--green); }

.toolbar { display: flex; align-items: center; gap: 10px; margin: 0 auto; }
.tool-group { display: flex; gap: 2px; padding: 3px; background: var(--panel); border-radius: 12px; }
.header-actions { display: flex; align-items: center; gap: 6px; min-width: 210px; justify-content: flex-end; }
.lang-toggle { margin-left: 6px; }

/* ---------- Main layout ---------- */
.app-main {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr) 296px;
}
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--white); }
.panel-left { border-right: 1px solid var(--border); }
.panel-right { border-left: 1px solid var(--border); }
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 18px 18px 12px;
}
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.panel-count { font-size: 12px; color: var(--muted); }

/* ---------- Library ---------- */
.search { position: relative; margin: 0 18px; }
.search .ico { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 38px; padding: 0 12px 0 35px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); outline: none;
}
.search input:focus { background: var(--white); border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px 6px; }
.chip {
  height: 28px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--white); color: var(--ink-2);
  font-size: 12.5px; cursor: pointer;
}
.chip:hover { background: var(--panel); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--white); }
.thumb-grid {
  flex: 1; min-height: 0; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 12px 10px; align-content: start;
  padding: 10px 18px 18px;
}
.thumb { display: flex; flex-direction: column; gap: 5px; min-width: 0; border-radius: 12px; cursor: grab; outline: none; user-select: none; -webkit-user-select: none; }
.app-header, .stage-bar, .chips, .icon-grid, .segmented { user-select: none; -webkit-user-select: none; }
.thumb:active { cursor: grabbing; }
.thumb-img {
  display: grid; place-items: center;
  aspect-ratio: 1; padding: 10px;
  border: 1px solid transparent; border-radius: 12px;
  background: var(--panel);
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}
.thumb-img img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.thumb:hover .thumb-img { background: var(--white); border-color: var(--border); box-shadow: var(--shadow); }
.thumb:focus-visible .thumb-img { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.thumb-name { font-size: 11.5px; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.library-empty { margin: 4px 18px; color: var(--muted); font-size: 13px; }

/* ---------- Stage ---------- */
.stage-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--stage); }
.stage-bar {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 50px; padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafafb;
}
.artboard-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.bar-label { font-size: 13px; color: var(--muted); }
.custom-size { display: inline-flex; align-items: center; gap: 6px; }
.times { color: var(--muted); }
.zoom-controls { display: flex; align-items: center; gap: 2px; }
.zoom-label {
  min-width: 58px; height: 32px; padding: 0 6px;
  border: 0; border-radius: 8px; background: transparent;
  font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink-2);
  cursor: pointer;
}
.zoom-label:hover { background: var(--panel); }

.stage-outer { position: relative; flex: 1; min-height: 0; }
.stage { position: absolute; inset: 0; display: flex; overflow: auto; }
.artboard-wrap { margin: auto; padding: 48px; }
.artboard {
  position: relative;
  background: var(--white);
  box-shadow: 0 0 0 1px rgba(17, 17, 17, .05), 0 2px 4px rgba(17, 17, 17, .05), 0 10px 32px rgba(17, 17, 17, .08);
}
.artboard.is-drop-target { box-shadow: 0 0 0 3px var(--blue), 0 10px 32px rgba(17, 17, 17, .1); }
.empty-hint {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 24px; text-align: center;
  color: var(--muted); pointer-events: none;
}
.empty-icon {
  display: grid; place-items: center;
  width: 56px; height: 56px; margin-bottom: 6px;
  border: 1.5px dashed #c9cdd2; border-radius: 16px; color: #9aa0a6;
}
.empty-icon .ico { width: 26px; height: 26px; }
.empty-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink-2); }
.empty-text { margin: 0; font-size: 13px; }

.pan-shield { position: absolute; inset: 0; z-index: 5; display: none; cursor: grab; }
.space-pan .pan-shield, .is-panning .pan-shield { display: block; }
.is-panning .pan-shield { cursor: grabbing; }

.banner {
  position: absolute; top: 14px; left: 50%; z-index: 6;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 16px;
  transform: translateX(-50%);
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--white); box-shadow: var(--shadow);
  font-size: 13.5px; white-space: nowrap;
}
.fatal {
  position: absolute; inset: 0; z-index: 7;
  display: grid; place-items: center; padding: 24px;
  background: var(--stage); color: var(--ink-2); text-align: center;
}
.fatal p { max-width: 420px; }

/* ---------- Properties ---------- */
.props-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 18px 24px; }
.prop-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0 14px; }
.prop-kind { font-size: 12px; color: var(--muted); }
.prop-name { font-size: 15px; font-weight: 650; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  background: rgba(238, 177, 67, .16); color: #8a5a07;
  font-size: 11.5px; font-weight: 600;
}
.badge .ico { width: 13px; height: 13px; }
.prop-section { padding: 16px 0; border-top: 1px solid var(--border); }
.prop-title {
  margin: 0 0 12px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}
.prop-row {
  display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: center; gap: 10px;
  min-height: 32px; margin-bottom: 10px;
}
.prop-label { font-size: 13px; color: var(--ink-2); }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(17, 17, 17, .16);
  cursor: pointer;
  transition: transform .1s;
}
.swatch:hover:not(:disabled) { transform: scale(1.08); }
.swatch:disabled { opacity: .3; cursor: default; }
.slider-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.slider { flex: 1; min-width: 0; margin: 0; accent-color: var(--ink); }
.slider-value { width: 52px; flex: none; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; font-size: 13px; cursor: pointer; }
.check.inline { margin: 0; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); cursor: pointer; }
.icon-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.icon-btn {
  display: grid; place-items: center;
  height: 36px; min-width: 36px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--white); color: var(--ink-2);
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--panel); }
.icon-btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--white); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.icon-btn-text { font-size: 15px; line-height: 1; }
.icon-btn.is-bold .icon-btn-text { font-weight: 800; }
.icon-btn.is-italic .icon-btn-text { font-style: italic; font-family: Georgia, "Times New Roman", serif; }

.props-empty { padding: 8px 0 18px; text-align: center; }
.props-empty-icon {
  display: grid; place-items: center;
  width: 44px; height: 44px; margin: 6px auto 10px;
  border-radius: 12px; background: var(--panel); color: var(--muted);
}
.props-empty-title { margin: 0 0 4px; font-weight: 650; }
.props-empty-text { margin: 0; font-size: 13px; color: var(--muted); }
.shortcuts { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; margin: 0; font-size: 12.5px; }
.shortcuts dt { color: var(--ink-2); }
.shortcuts dd { margin: 0; text-align: right; }
.shortcuts kbd {
  display: inline-block; padding: 1px 6px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--panel); color: var(--ink-2);
  font-size: 11.5px; white-space: nowrap;
}

/* ---------- Color popover ---------- */
.color-popover {
  position: fixed; z-index: 50;
  width: 244px; padding: 12px;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--white); box-shadow: var(--shadow-lg);
}
.popover-title { margin: 0 0 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.palette-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.palette-swatch {
  aspect-ratio: 1; padding: 0;
  border: 0; border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(17, 17, 17, .16);
  cursor: pointer;
}
.palette-swatch:hover { transform: scale(1.1); }
.palette-swatch.is-current { box-shadow: inset 0 0 0 1px rgba(17, 17, 17, .16), 0 0 0 2px var(--white), 0 0 0 4px var(--blue); }
.palette-sep { height: 1px; margin: 10px 0; background: var(--border); }
.custom-color { display: flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; }
.custom-color input[type="color"] {
  width: 36px; height: 30px; padding: 2px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--white); cursor: pointer;
}

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(17, 17, 17, .28); }
.modal-card { width: min(440px, 100%); padding: 20px 22px 22px; border-radius: 18px; background: var(--white); box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.field { margin-bottom: 14px; }
.field-label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.export-info, .modal-hint { min-height: 20px; margin: 4px 0 18px; font-size: 13px; color: var(--muted); }
.select-block { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 70;
  max-width: calc(100vw - 32px); padding: 10px 16px;
  border-radius: 10px; background: var(--ink); color: var(--white);
  font-size: 13.5px;
  opacity: 0; pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity .18s, transform .18s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Narrower screens ---------- */
@media (max-width: 1240px) {
  .app-main { grid-template-columns: 248px minmax(0, 1fr) 272px; }
  .brand, .header-actions { min-width: 0; }
  .header-actions .btn-label { display: none; }
  .header-actions .btn { padding: 0 10px; }
}
@media (max-width: 900px) {
  body { overflow: auto; height: auto; }
  .app-header { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  .toolbar { order: 3; width: 100%; justify-content: center; margin: 0; }
  .header-actions { margin-left: auto; }
  .app-main { display: flex; flex-direction: column; }
  .panel-left { max-height: 320px; border-right: 0; border-bottom: 1px solid var(--border); }
  .stage-col { height: 72vh; min-height: 420px; }
  .panel-right { border-left: 0; border-top: 1px solid var(--border); }
  .props-body { overflow: visible; }
  .banner { white-space: normal; width: calc(100% - 32px); }
}

/* shape type picker next to the shape tool */
.shape-kind { width: auto; max-width: 160px; height: 32px; margin-left: 4px; padding: 0 8px; font-size: 12px; }
