@font-face {
  font-family: "Cairo";
  src: url("./assets/Cairo.ttf") format("truetype");
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: "Cairo", sans-serif;
  font-synthesis: none;
  color: #282b26;
  background: #f4f2ec;
  --ink: #282b26;
  --muted: #76796e;
  --gold: #b4873d;
  --gold-light: #d9b56b;
  --line: #e2dfd4;
  --panel: #fffefb;
  --focus: #9b6c21;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; -webkit-font-smoothing: antialiased; }
button, input, output, a { -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled, a[aria-disabled="true"] { cursor: wait; opacity: .5; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
svg { display: block; flex: 0 0 auto; }
h1, h2, p { margin: 0; }

.app-header {
  max-width: 1200px;
  padding: 28px 28px 24px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}
.brand { display: inline-flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; border-radius: 10px; }
.brand-mark { display: flex; width: 58px; height: 58px; align-items: center; justify-content: center; background: #262822; border: 1px solid #383b30; border-radius: 14px; padding: 7px; box-shadow: 0 3px 8px #282b260b; }
.brand-mark img { display: block; width: 100%; height: auto; }
.brand-copy { display: flex; flex-direction: column; gap: 0; }
.brand-name { color: #8b7448; font-size: 11px; line-height: 1.7; letter-spacing: .11em; text-transform: uppercase; font-weight: 700; }
.brand-title { font-size: 23px; line-height: 1.4; font-weight: 750; letter-spacing: -.035em; }
.intro { max-width: 310px; color: var(--muted); font-size: 13px; line-height: 1.8; text-align: right; }

.workspace { max-width: 1200px; margin: 0 auto; padding: 0 28px; display: grid; grid-template-columns: minmax(0, 1fr) 332px; align-items: start; gap: 28px; }
.design-panel { min-width: 0; }
.design-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.design-heading h1 { font-size: 14px; font-weight: 700; }
.template-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-bottom: 18px; }
.template-button { position: relative; min-width: 0; min-height: 74px; display: flex; gap: 10px; align-items: center; text-align: left; background: #faf9f5; border: 1px solid var(--line); border-radius: 12px; padding: 8px; color: var(--ink); transition: background .15s, border-color .15s, box-shadow .15s; }
.template-button:hover { background: #fffefb; border-color: #c7b590; }
.template-button[aria-pressed="true"] { background: #fffcf4; border-color: #b7924f; box-shadow: 0 0 0 1px #b7924f; }
.template-thumbnail { width: 52px; height: 52px; object-fit: cover; border-radius: 7px; flex-shrink: 0; }
.template-copy { display: flex; min-width: 0; flex-direction: column; gap: 1px; }
.template-name { font-size: 11px; line-height: 1.35; font-weight: 750; }
.template-tone { font-size: 10px; color: var(--muted); line-height: 1.5; }
.template-check { position: absolute; right: 4px; top: 4px; width: 15px; height: 15px; opacity: 0; }
.template-check circle { fill: #a67c32; stroke: #fffcf4; stroke-width: 1.5; }
.template-check path { fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.template-button[aria-pressed="true"] .template-check { opacity: 1; }

#stage { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; isolation: isolate; border-radius: 16px; background: #252820; box-shadow: 0 12px 35px #2c2b2420, 0 2px 4px #2c2b2414; }
#card-canvas { display: block; width: 100%; height: 100%; }
#stage-inputs { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.card-input { position: absolute; display: block; min-width: 0; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 8px; background: transparent; color: transparent; caret-color: transparent; -webkit-text-fill-color: transparent; font-family: "Cairo", sans-serif; font-size: 16px; line-height: 1; text-align: center; direction: ltr; cursor: text; pointer-events: auto; appearance: none; -webkit-appearance: none; box-shadow: none; }
.card-input::placeholder { color: transparent; -webkit-text-fill-color: transparent; opacity: 0; }
.card-input::selection { color: transparent; background: transparent; }
.card-input:focus, .card-input:focus-visible { outline: 3px solid #fff4c9; outline-offset: -3px; box-shadow: inset 0 0 0 5px #8f6e2f7a; background: transparent; }
#card-loading { position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; padding: 24px; background: #262921; color: #ead9b2; font-size: 13px; text-align: center; }
.loading-ring { width: 28px; height: 28px; border: 2px solid #d4af6226; border-top-color: #d4af62; border-radius: 50%; animation: loading-spin .9s linear infinite; }
@keyframes loading-spin { to { transform: rotate(360deg); } }

.control-panel { min-width: 0; margin-top: 0; padding: 23px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 5px 16px #282b2604; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 17px; }
.section-heading h2 { font-size: 17px; font-weight: 750; letter-spacing: -.02em; }
#filled-count { color: var(--muted); font-size: 11px; white-space: nowrap; }
.field-group + .field-group { margin-top: 14px; }
.field-group label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 15px; font-weight: 700; }
.label-translation { color: var(--muted); font-size: 11px; font-weight: 500; }
.field-input { display: block; width: 100%; height: 51px; padding: 6px 13px; border: 1px solid #dcd9cd; border-radius: 9px; background: #faf9f5; color: var(--ink); font-size: 22px; line-height: 1.5; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; transition: border-color .15s, background .15s; }
.field-input::placeholder { color: #9a9b92; font-size: 13px; font-weight: 400; }
.field-input:hover { border-color: #b7b4a6; }
.field-input:focus { background: #fff; border-color: #a78545; outline: 2px solid #d6ba8340; outline-offset: 1px; }
.type-section { margin-top: 22px; padding-top: 17px; border-top: 1px solid #ebe8de; }
.type-heading { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.type-heading label { font-size: 13px; font-weight: 700; }
.size-readout { display: inline-flex; align-items: baseline; justify-content: flex-end; gap: 4px; min-width: 48px; font-size: 11px; color: var(--muted); }
#type-size-value { font-size: 15px; color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
#type-size { display: block; width: 100%; height: 44px; margin: 0; accent-color: #aa823a; cursor: pointer; }
#font-match-note { color: var(--muted); font-size: 11px; line-height: 1.7; }
.export-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 21px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; width: 100%; min-height: 49px; padding: 10px 15px; border-radius: 10px; border: 1px solid transparent; font-family: "Cairo", sans-serif; font-size: 14px; font-weight: 750; text-align: center; text-decoration: none; line-height: 1.6; cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s; }
.button svg, .utility-button svg, .icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.button-primary { background: #c7a052; color: #282b21; border-color: #bf9746; box-shadow: 0 2px 3px #8b6d1f0d; }
.button-primary:hover { background: #d2ac60; border-color: #b98e3c; }
.button-secondary { background: #292d25; color: #f8f5ed; border-color: #292d25; }
.button-secondary:hover { background: #3c4136; border-color: #3c4136; }
.utility-actions { display: grid; grid-template-columns: auto auto; justify-content: space-between; gap: 6px; margin-top: 10px; }
.utility-button { min-width: 0; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 6px 2px; border: 0; border-radius: 7px; background: transparent; color: #747769; font-size: 10px; font-weight: 600; white-space: nowrap; }
.utility-button svg { width: 15px; height: 15px; }
.utility-button:hover { color: #856424; background: #f5f1e8; }
#status { min-height: 33px; padding-top: 12px; border-top: 1px solid #ebe8de; color: #7c7f72; font-size: 11px; line-height: 1.7; text-align: center; overflow-wrap: anywhere; }
#status[data-tone="error"], #status.error { color: #a13e2f; }
#status[data-tone="success"], #status.success { color: #526849; }
.app-footer { max-width: 1200px; margin: 0 auto; padding: 24px 28px 28px; color: #8b8d82; font-size: 11px; text-align: center; }

#export-dialog { width: min(92vw, 520px); max-height: 92dvh; margin: auto; padding: 20px; overflow: auto; border: 1px solid #e4dfd2; border-radius: 18px; background: #fffef9; color: var(--ink); box-shadow: 0 24px 90px #15180e66; }
#export-dialog::backdrop { background: #171a13b8; backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.dialog-heading h2 { font-size: 19px; font-weight: 750; }
.icon-button { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 10px; background: #f6f4ed; color: #5c6154; }
.icon-button:hover { background: #ece9de; }
#export-image { display: block; width: 100%; height: auto; border-radius: 10px; background: #292d25; }
.export-help { margin: 15px 0; color: var(--muted); font-size: 12px; line-height: 1.8; }

@media (max-width: 1000px) and (min-width: 761px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; }
  .control-panel { padding: 20px; }
  .template-button { flex-direction: column; justify-content: center; gap: 6px; text-align: center; }
  .template-thumbnail { width: 45px; height: 45px; }
  .template-copy { min-height: 32px; justify-content: center; }
  .template-name { font-size: 10px; }
  .template-tone { font-size: 9px; }
}

@media (max-width: 760px) {
  .app-header { max-width: 590px; padding: 23px 18px 21px; flex-direction: column; align-items: flex-start; gap: 12px; }
  .brand-mark { width: 50px; height: 50px; border-radius: 12px; padding: 6px; }
  .brand-title { font-size: 22px; }
  .brand-name { font-size: 10px; }
  .intro { max-width: none; font-size: 12px; line-height: 1.7; text-align: left; }
  .workspace { max-width: 590px; padding: 0 18px; grid-template-columns: minmax(0, 1fr); gap: 23px; }
  .design-heading { margin-bottom: 10px; }
  .design-heading h1 { font-size: 13px; }
  .template-picker { gap: 8px; margin-bottom: 15px; }
  .template-button { min-height: 105px; padding: 9px 5px 8px; flex-direction: column; justify-content: flex-start; gap: 7px; text-align: center; }
  .template-thumbnail { width: 48px; height: 48px; border-radius: 6px; }
  .template-copy { gap: 2px; }
  .template-name { font-size: 10px; line-height: 1.35; }
  .template-tone { font-size: 9px; }
  #stage { border-radius: 12px; box-shadow: 0 8px 22px #2c2b2420, 0 2px 4px #2c2b2410; }
  .card-input { border-radius: 5px; }
  .card-input:focus, .card-input:focus-visible { outline-width: 2px; outline-offset: -2px; box-shadow: inset 0 0 0 4px #8f6e2f7a; }
  .control-panel { padding: 21px; border-radius: 15px; }
  .section-heading { margin-bottom: 18px; }
  .section-heading h2 { font-size: 18px; }
  #filled-count { font-size: 11px; }
  .field-group + .field-group { margin-top: 15px; }
  .field-group label { font-size: 16px; }
  .label-translation { font-size: 12px; }
  .field-input { height: 53px; font-size: 23px; }
  .type-section { margin-top: 21px; }
  #font-match-note { font-size: 11px; }
  .export-actions { margin-top: 21px; }
  .button { min-height: 51px; }
  .utility-button { padding: 7px 3px; font-size: 11px; gap: 6px; }
  .utility-button svg { width: 16px; height: 16px; }
  #status { font-size: 11px; }
  .app-footer { padding: 20px 18px 28px; }
}

@media (max-width: 350px) {
  .app-header { padding-inline: 13px; }
  .workspace { padding-inline: 13px; }
  .control-panel { padding: 18px; }
  .template-name { font-size: 9px; }
  .utility-button { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
