@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

.afqg-app {
  --background: 136 17% 94%;
  --foreground: 168 18% 12%;
  --border: 154 11% 84%;
  --input: 154 11% 84%;
  --ring: 168 50% 34%;
  --card: 0 0% 100%;
  --card-foreground: 168 18% 12%;
  --primary: 176 50% 25%;
  --primary-foreground: 0 0% 100%;
  --secondary: 160 20% 91%;
  --secondary-foreground: 176 50% 25%;
  --muted: 147 17% 89%;
  --muted-foreground: 164 11% 39%;
  --accent: 168 71% 51%;
  --accent-foreground: 176 50% 15%;
  --destructive: 3 61% 48%;
  --destructive-foreground: 0 0% 100%;
  --radius: 3px;
  --app-font-sans: 'Manrope', sans-serif;
  --app-font-mono: 'DM Mono', monospace;
  --shadow-soft: 0 18px 40px rgba(23, 35, 33, 0.06);
  --shadow-card: 0 6px 18px rgba(23, 35, 33, 0.05), 0 1px 2px rgba(23, 35, 33, 0.04);
}

.afqg-app.afqg-theme-dark {
  --background: 170 20% 12%;
  --foreground: 143 22% 92%;
  --border: 164 14% 26%;
  --input: 164 14% 26%;
  --ring: 168 71% 51%;
  --card: 170 18% 16%;
  --card-foreground: 143 22% 92%;
  --primary: 168 71% 51%;
  --primary-foreground: 176 50% 15%;
  --secondary: 170 15% 23%;
  --secondary-foreground: 143 22% 92%;
  --muted: 170 15% 22%;
  --muted-foreground: 143 10% 66%;
  --accent: 168 71% 51%;
  --accent-foreground: 176 50% 15%;
  --destructive: 3 61% 58%;
  --destructive-foreground: 0 0% 100%;
}

.afqg-app {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--app-font-sans);
  min-height: 100dvh;
  display: flex;
}

.afqg-app * { box-sizing: border-box; border-color: hsl(var(--border)); }
.afqg-app [hidden] { display: none !important; }
.afqg-app button, .afqg-app input, .afqg-app textarea, .afqg-app select { font: inherit; }
.afqg-app button, .afqg-app a, .afqg-app input, .afqg-app textarea, .afqg-app select { -webkit-tap-highlight-color: transparent; }
.afqg-app button:focus-visible, .afqg-app a:focus-visible, .afqg-app input:focus-visible, .afqg-app textarea:focus-visible, .afqg-app select:focus-visible { outline: 3px solid hsl(var(--accent) / .65); outline-offset: 3px; }

.afqg-app .app-shell { min-height: 100dvh; display: flex; background: hsl(var(--background)); width: 100%; }
.afqg-app .workspace { min-width: 0; flex: 1; }
.afqg-app .topbar { height: 76px; padding: 0 38px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid hsl(var(--border)); background: hsl(var(--background) / .94); }
.afqg-app .eyebrow { color: hsl(var(--muted-foreground)); font-family: var(--app-font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.afqg-app .page-title { margin: 3px 0 0; font-size: 19px; letter-spacing: -.045em; font-weight: 800; }
.afqg-app .top-actions { display: flex; align-items: center; gap: 9px; }
.afqg-app .icon-button, .afqg-app .ghost-button, .afqg-app .primary-button, .afqg-app .outline-button { border: 1px solid transparent; border-radius: var(--radius); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 13px; cursor: pointer; transition: transform .2s ease, background .2s ease, border-color .2s ease, color .2s ease; }
.afqg-app .icon-button { width: 36px; padding: 0; color: hsl(var(--muted-foreground)); background: transparent; }
.afqg-app .icon-button:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); transform: translateY(-1px); }
.afqg-app .primary-button { border-color: hsl(var(--primary)); background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); font-size: 12px; font-weight: 700; box-shadow: 0 4px 9px hsl(var(--primary) / .14); }
.afqg-app .primary-button:hover { transform: translateY(-1px); background: hsl(176 50% 21%); }
.afqg-app .primary-button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.afqg-app .outline-button { border-color: hsl(var(--border)); background: hsl(var(--card)); color: hsl(var(--foreground)); font-size: 12px; font-weight: 700; }
.afqg-app .outline-button:hover { border-color: hsl(var(--primary) / .4); background: hsl(var(--secondary)); transform: translateY(-1px); }
.afqg-app .ghost-button { color: hsl(var(--muted-foreground)); background: transparent; font-size: 12px; font-weight: 700; }
.afqg-app .ghost-button:hover { color: hsl(var(--primary)); background: hsl(var(--secondary)); }
.afqg-app .main-content { max-width: 1510px; margin: 0 auto; padding: 29px 38px 54px; }
.afqg-app .studio-layout { display: grid; grid-template-columns: minmax(300px, .94fr) minmax(380px, 1.22fr) minmax(265px, .76fr); gap: 18px; align-items: start; }
.afqg-app .panel { min-width: 0; border: 1px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--card)); box-shadow: var(--shadow-card); }
.afqg-app .panel-header { min-height: 61px; padding: 15px 17px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid hsl(var(--border)); }
.afqg-app .panel-title { display: flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 800; letter-spacing: -.01em; color: hsl(var(--foreground)); }
.afqg-app .panel-title svg { color: hsl(var(--primary)); }
.afqg-app .panel-kicker { color: hsl(var(--muted-foreground)); font-family: var(--app-font-mono); font-size: 10px; }
.afqg-app .panel-body { padding: 17px; }
.afqg-app .type-grid { display: flex; flex-wrap: wrap; gap: 7px; padding-right: 3px; max-height: none !important; overflow: visible !important; }
.afqg-app .type-chip { border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 10px 14px; color: hsl(var(--foreground)); background: hsl(var(--background)); cursor: pointer; font-size: 14px; line-height: 1.3; font-weight: 700; transition: transform .18s ease, background .18s ease, border-color .18s ease, color .18s ease; }
.afqg-app .type-chip:hover { border-color: hsl(var(--primary) / .45); color: hsl(var(--primary)); transform: translateY(-1px); }
.afqg-app .type-chip.selected { border-color: hsl(var(--primary)); color: hsl(var(--primary)); background: hsl(var(--secondary)); font-weight: 800; box-shadow: inset 0 0 0 1px hsl(var(--primary) / .08); }
.afqg-app .field-stack { display: grid; gap: 13px; }
.afqg-app .field-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; color: hsl(var(--foreground)); font-size: 13px; font-weight: 800; }
.afqg-app .field-hint { color: hsl(var(--muted-foreground)); font-family: var(--app-font-mono); font-weight: 500; font-size: 10px; }
.afqg-app .field-input, .afqg-app .field-select, .afqg-app .field-textarea { width: 100%; border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 10px 11px; color: hsl(var(--foreground)); background: hsl(var(--background)); font-size: 12px; transition: border-color .2s ease, box-shadow .2s ease, background .2s ease; }
.afqg-app .field-input[type="file"] { padding: 6px; font-size: 11px; background: hsl(var(--card)); cursor: pointer; }
.afqg-app .field-input[type="file"]::file-selector-button { border: 1px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--secondary)); color: hsl(var(--foreground)); font-size: 10px; font-weight: 700; padding: 4px 8px; margin-right: 10px; cursor: pointer; transition: background .2s ease; }
.afqg-app .field-input[type="file"]::file-selector-button:hover { background: hsl(var(--border)); }
.afqg-app .logo-field { margin-top: 13px; }
.afqg-app .logo-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: stretch; }
.afqg-app .logo-actions .outline-button { min-height: 40px; }
.afqg-app .logo-note { margin: 6px 0 0; color: hsl(var(--muted-foreground)); font-size: 10px; font-weight: 600; line-height: 1.45; }
.afqg-app .field-input:hover, .afqg-app .field-select:hover, .afqg-app .field-textarea:hover { border-color: hsl(var(--primary) / .35); }
.afqg-app .field-input:focus, .afqg-app .field-select:focus, .afqg-app .field-textarea:focus { border-color: hsl(var(--primary)); box-shadow: 0 0 0 3px hsl(var(--accent) / .13); outline: none; background: hsl(var(--card)); }
.afqg-app .field-textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
.afqg-app .field-select { appearance: auto; }
.afqg-app .two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.afqg-app .editor-divider { height: 1px; margin: 18px 0 16px; background: hsl(var(--border)); }
.afqg-app .section-caption { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; color: hsl(var(--muted-foreground)); font-family: var(--app-font-mono); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.afqg-app .color-row { display: flex; gap: 10px; }
.afqg-app .color-field { flex: 1; min-width: 0; }
.afqg-app .color-input { width: 100%; height: 34px; padding: 3px; border: 1px solid hsl(var(--border)); border-radius: var(--radius); background: hsl(var(--background)); cursor: pointer; }
.afqg-app .range-row { display: grid; grid-template-columns: minmax(0, 1fr) 42px; align-items: center; gap: 12px; min-height: 24px; }
.afqg-app input.range-input[type="range"] { -webkit-appearance: none !important; appearance: none !important; display: block !important; width: 100% !important; min-width: 120px !important; height: 8px !important; min-height: 8px !important; margin: 8px 0 !important; padding: 0 !important; border: 0 !important; border-radius: 3px !important; background: linear-gradient(to right, hsl(var(--primary)) 0 var(--range-progress, 0%), hsl(var(--border)) var(--range-progress, 0%) 100%) !important; box-shadow: inset 0 0 0 1px hsl(var(--foreground) / .12) !important; opacity: 1 !important; cursor: pointer; }
.afqg-app input.range-input[type="range"]::-webkit-slider-runnable-track { width: 100%; height: 8px; border: 0; border-radius: 3px; background: transparent; }
.afqg-app input.range-input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none !important; appearance: none !important; width: 20px !important; height: 20px !important; margin-top: -6px; border: 2px solid hsl(var(--card)) !important; border-radius: 3px !important; background: hsl(var(--primary)) !important; box-shadow: 0 0 0 1px hsl(var(--primary)); cursor: pointer; }
.afqg-app input.range-input[type="range"]::-moz-range-track { width: 100%; height: 8px; border: 0; border-radius: 3px; background: hsl(var(--border)); }
.afqg-app input.range-input[type="range"]::-moz-range-progress { height: 8px; border-radius: 3px; background: hsl(var(--primary)); }
.afqg-app input.range-input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border: 2px solid hsl(var(--card)); border-radius: 3px; background: hsl(var(--primary)); box-shadow: 0 0 0 1px hsl(var(--primary)); cursor: pointer; }
.afqg-app .range-value { min-width: 42px; color: hsl(var(--primary)); font-family: var(--app-font-mono); font-size: 12px; font-weight: 700; text-align: right; }
.afqg-app .preview-panel { overflow: hidden; }
.afqg-app .preview-body { padding: 26px 24px 21px; background: linear-gradient(145deg, hsl(var(--background)), hsl(var(--secondary) / .48)); }
.afqg-app .qr-stage { position: relative; display: grid; place-items: center; min-height: 330px; border: 1px dashed hsl(var(--primary) / .3); border-radius: var(--radius); background: hsl(var(--background)); overflow: hidden; }
.afqg-app .qr-stage::before, .afqg-app .qr-stage::after { content: ''; position: absolute; width: 18px; height: 18px; border-color: hsl(var(--accent)); border-style: solid; opacity: .75; }
.afqg-app .qr-stage::before { top: 15px; left: 15px; border-width: 2px 0 0 2px; }
.afqg-app .qr-stage::after { right: 15px; bottom: 15px; border-width: 0 2px 2px 0; }
.afqg-app .qr-wrap { position: relative; padding: 17px; background: hsl(var(--background)); box-shadow: 0 13px 30px hsl(var(--primary) / .09); transition: transform .25s ease; max-width: 100%; border-radius: var(--radius); }
.afqg-app .qr-wrap:hover { transform: translateY(-2px) rotate(.4deg); }
.afqg-app .qr-svg { display: block; width: min(285px, 59vw); height: auto; shape-rendering: crispEdges; }
.afqg-app .qr-badge { position: absolute; top: 50%; left: 50%; display: grid; place-items: center; width: 38px; height: 38px; border: 5px solid hsl(var(--background)); border-radius: var(--radius); transform: translate(-50%, -50%); background: hsl(var(--primary)); color: hsl(var(--accent)); font-family: var(--app-font-mono); font-size: 9px; font-weight: 500; letter-spacing: -.08em; }
.afqg-app .frame-preset { border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 8px 4px; background: hsl(var(--background)); color: hsl(var(--muted-foreground)); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; transition: all 0.2s; }
.afqg-app .frame-preset span { font-size: 10px !important; line-height: 1.1; font-weight: 800 !important; }
.afqg-app .frame-preset:hover { border-color: hsl(var(--primary)/0.4); color: hsl(var(--primary)); }
.afqg-app .frame-preset.selected { border-color: hsl(var(--primary)); color: hsl(var(--primary)); background: hsl(var(--secondary)); box-shadow: 0 0 0 1px hsl(var(--primary)/0.2); }
.afqg-app .preview-meta { display: flex; align-items: center; justify-content: space-between; padding: 14px 17px; border-top: 1px solid hsl(var(--border)); }
.afqg-app .preview-meta-copy { min-width: 0; }
.afqg-app .preview-meta-label { color: hsl(var(--muted-foreground)); font-family: var(--app-font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }
.afqg-app .preview-meta-value { margin-top: 4px; overflow: hidden; color: hsl(var(--foreground)); font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.afqg-app .preview-status { display: inline-flex; align-items: center; gap: 6px; color: hsl(var(--primary)); font-family: var(--app-font-mono); font-size: 9px; white-space: nowrap; }
.afqg-app .status-dot { width: 6px; height: 6px; border-radius: var(--radius); background: hsl(var(--accent)); box-shadow: 0 0 0 4px hsl(var(--accent) / .16); }
.afqg-app .action-stack { display: grid; gap: 8px; }
.afqg-app .action-stack button { width: 100%; }
.afqg-app .hint-box { margin-top: 14px; padding: 13px; border-radius: var(--radius); background: hsl(var(--secondary)); }
.afqg-app .hint-box p { margin: 0; color: hsl(var(--secondary-foreground) / .75); font-size: 10px; line-height: 1.5; }
.afqg-app .saved-section { display: none !important; }
.afqg-app .saved-list { padding: 4px 17px 13px; display: flex; flex-direction: column; }
.afqg-app .saved-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid hsl(var(--border)); }
.afqg-app .saved-row:last-child { border-bottom: 0; }
.afqg-app .saved-main { min-width: 0; display: flex; align-items: center; gap: 10px; }
.afqg-app .saved-icon { display: grid; place-items: center; flex: 0 0 31px; width: 31px; height: 31px; border-radius: var(--radius); color: hsl(var(--primary)); background: hsl(var(--secondary)); }
.afqg-app .saved-info { min-width: 0; display: flex; flex-direction: column; }
.afqg-app .saved-name { overflow: hidden; color: hsl(var(--foreground)); font-size: 11px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.afqg-app .saved-detail { margin-top: 3px; overflow: hidden; color: hsl(var(--muted-foreground)); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.afqg-app .saved-actions { display: flex; align-items: center; gap: 3px; }
.afqg-app .small-icon { width: 29px; height: 29px; padding: 0; border: 0; border-radius: var(--radius); display: grid; place-items: center; color: hsl(var(--muted-foreground)); background: transparent; cursor: pointer; }
.afqg-app .small-icon:hover { color: hsl(var(--primary)); background: hsl(var(--secondary)); }
.afqg-app .empty-state { margin: 14px 0; padding: 25px; border: 1px dashed hsl(var(--border)); border-radius: var(--radius); color: hsl(var(--muted-foreground)); font-size: 11px; text-align: center; }
.afqg-app .toast { display: none !important; }
.afqg-app .toast.is-visible { opacity: 1; pointer-events: auto; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1180px) {
  .afqg-app .topbar, .afqg-app .main-content { padding-left: 24px; padding-right: 24px; }
  .afqg-app .studio-layout { grid-template-columns: minmax(280px, .9fr) minmax(350px, 1.1fr); }
  .afqg-app .actions-column { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
  .afqg-app .actions-column .panel { height: 100%; }
}
@media (max-width: 820px) {
  .afqg-app .topbar { height: 68px; padding: 0 17px; }
  .afqg-app .top-actions .outline-button { display: none; }
  .afqg-app .main-content { padding: 24px 17px 42px; }
  .afqg-app .studio-layout { grid-template-columns: 1fr; }
  .afqg-app .actions-column { grid-column: auto; display: block; }
  .afqg-app .actions-column .panel { margin-bottom: 18px; }
}
@media (max-width: 460px) {
  .afqg-app .page-title { overflow: visible !important; font-size: 14px !important; line-height: 1.25; text-overflow: clip !important; white-space: normal !important; }
  .afqg-app .top-actions .icon-button:first-of-type { display: none; }
  .afqg-app .panel-body, .afqg-app .preview-body { padding: 14px; }
  .afqg-app .qr-stage { min-height: 280px; }
  .afqg-app .qr-svg { width: min(240px, 67vw); height: min(240px, 67vw); }
  .afqg-app .saved-row { grid-template-columns: 1fr; gap: 7px; }
  .afqg-app .saved-actions { justify-content: flex-end; }
}
