/* The editor page (E06, E07). Layout and the parts that only the editor has.
   The look of buttons, inputs, tabs, dialogs and the rest comes from shadcn.css (shadcn/ui components) and tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
.brand { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -48px; z-index: 50; background: var(--primary); color: var(--primary-foreground); padding: 8px 12px; border-radius: var(--radius-md); }
.skip:focus { top: 8px; }
/* A fallback ring for anything that has no ring of its own. Components in shadcn.css have their own. */
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.noscript { padding: 16px; text-align: center; }

/* The editor fills the window. The footer is below it: scroll down to reach it. */
.shell { display: flex; flex-direction: column; height: 100dvh; min-height: 520px; }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--background); flex: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.2px; font-size: 16px; white-space: nowrap; color: inherit; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, #667eea, #ec4899); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.ico { width: 18px; height: 18px; flex: none; }
.lock { width: 15px; height: 15px; opacity: .7; }
.file-btn { cursor: pointer; position: relative; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

/* layout */
.app { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.stage { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; padding: 24px; background: var(--muted); overflow: hidden; outline: none; }
.panel { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--border); background: var(--background); }

/* drop area */
.drop { width: 100%; height: 100%; display: grid; place-items: center; border: 2px dashed var(--border); border-radius: 24px; transition: background .15s, border-color .15s; }
.drop.over { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, transparent); }
.drop-card { text-align: center; max-width: 460px; padding: 24px; display: grid; gap: 12px; justify-items: center; }
.drop-card h2 { font-size: 28px; line-height: 1.15; letter-spacing: -0.8px; font-weight: 600; text-wrap: balance; }
.drop-card p { color: var(--muted-foreground); }
.drop-ico { width: 44px; height: 44px; color: var(--muted-foreground); }
.drop-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }

/* preview */
.view { position: relative; line-height: 0; }
.view[hidden], .drop[hidden] { display: none; }
#preview { display: block; border-radius: 4px; box-shadow: var(--shadow-lg); background: repeating-conic-gradient(#8883 0 25%, transparent 0 50%) 0 0 / 14px 14px; }
.overlay { position: absolute; inset: 0; touch-action: none; }
.overlay.drawing { cursor: crosshair; }
/* With a drawing tool chosen, existing items must not catch the pointer: a new item can start on top of them. */
.overlay.drawing .ann, .overlay.drawing .handle, .overlay.drawing svg * { pointer-events: none !important; }
.ann { position: absolute; border: 2px solid transparent; border-radius: 3px; cursor: move; pointer-events: auto; }
.ann.sel { border-color: #3b82f6; }
.ann.redact { background: rgba(59,130,246,.0); }
.ann.draft { border: 2px dashed #3b82f6; background: rgba(17,24,39,.55); }
.ann:focus-visible { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #3b82f6; }
.handle { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #fff; border: 2px solid #3b82f6; cursor: nwse-resize; pointer-events: auto; touch-action: none; }
.arrow-line { position: absolute; height: 0; transform-origin: 0 0; border-top: 2px dashed #3b82f6; pointer-events: none; }
/* The inline editor of a text label. The selector is stronger on purpose than the shadcn text input rules (width 100%, height 36px,
   a clear dark background): without it the box fills the whole image width and runs past the image. The width is set in annotate-ui.js. */
:root .overlay input.label-edit[type="text"] { position: absolute; z-index: 5; width: auto; min-width: 96px; height: auto; padding: 2px 8px; font: 600 16px/1.3 var(--font-sans); background: #fff; color: #111; border: 2px solid #3b82f6; border-radius: 6px; }
/* The floating bar above the selected item (copy, delete) and the round handle that turns it. Both sit on top of the preview.
   .view has line-height 0, so the bar sets its own. Colours come from the theme tokens, so dark mode follows. */
.sel-bar { position: absolute; z-index: 6; display: flex; align-items: center; gap: 2px; padding: 4px; line-height: 1; border-radius: 999px; background: var(--popover); color: var(--popover-foreground); border: 1px solid var(--border); box-shadow: var(--shadow-lg); touch-action: none; }
.sel-bar button { appearance: none; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: inherit; cursor: pointer; }
.sel-bar button:hover { background: var(--accent); }
.sel-bar button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.sel-bar button.danger:hover { color: var(--destructive); }
.sel-bar .ico { width: 18px; height: 18px; }
.rot-handle { position: absolute; z-index: 5; width: 28px; height: 28px; margin: -14px 0 0 -14px; padding: 0; display: grid; place-items: center; border-radius: 50%; background: var(--popover); color: var(--popover-foreground); border: 1px solid var(--border); box-shadow: var(--shadow-lg); cursor: grab; touch-action: none; }
.rot-handle:active { cursor: grabbing; }
.rot-handle .ico { width: 16px; height: 16px; pointer-events: none; }
.notes { position: absolute; left: 12px; right: 12px; bottom: 10px; text-align: center; font-size: 12.5px; color: var(--muted-foreground); pointer-events: none; }

/* panes (the tab list itself is in shadcn.css) */
.panes { flex: 1 1 auto; min-height: 0; overflow: auto; }
.pane { padding: 16px; display: grid; gap: 14px; align-content: start; }
.pane[hidden] { display: none; }
.pane-title { font-size: 16px; letter-spacing: -0.2px; font-weight: 600; }
.sub { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground); font-weight: 600; margin-top: 6px; display: flex; justify-content: space-between; align-items: baseline; }
.count { text-transform: none; letter-spacing: 0; font-weight: 500; }

.grid { display: grid; gap: 10px; }
.frames { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.frame-btn { position: relative; display: grid; gap: 6px; min-width: 0; width: 100%; padding: 6px; cursor: pointer; text-align: left; }
.frame-btn canvas { width: 100%; max-width: 100%; height: auto; display: block; border-radius: var(--radius-md); }
.frame-btn span { font-size: 12.5px; font-weight: 500; padding: 0 2px 2px; }
.badge { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; }
.badge .ico { width: 13px; height: 13px; }

.sw-group { display: grid; gap: 8px; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.sw { aspect-ratio: 1; padding: 0; overflow: hidden; background: var(--muted); cursor: pointer; }
.sw canvas { width: 100%; height: 100%; display: block; }

.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: center; gap: 10px; }
.row.stack { grid-template-columns: 1fr; }
.row label, .row > span:first-child { font-weight: 500; }
.range { display: grid; grid-template-columns: minmax(0, 1fr) 34px; gap: 8px; align-items: center; }
.range output { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted-foreground); font-size: 12.5px; }
.colors { display: flex; gap: 8px; }
.tools button span { font-size: 13px; }

.premium-box { border: 1px dashed var(--border); border-radius: var(--radius-lg); padding: 12px; display: grid; gap: 8px; }
.premium-head { display: flex; justify-content: space-between; align-items: center; }
.palette { display: flex; flex-wrap: wrap; gap: 8px; }
.palette button { width: 44px; height: 44px; border-radius: var(--radius-md); border: 1px solid var(--border); cursor: pointer; position: relative; padding: 0; }
.palette.locked button { filter: grayscale(.9) blur(1.5px); }

/* the format tiles in the Frame tab: a small picture of the shape, the name and the pixel size. Two columns, like the frames. */
.sizes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.size-btn { display: grid; grid-template-columns: 34px minmax(0, 1fr); grid-template-areas: "shape name" "shape dim"; column-gap: 10px; row-gap: 0; align-items: center; padding: 8px 10px; cursor: pointer; text-align: left; }
.size-btn .shape { grid-area: shape; width: 26px; margin: 0 auto; border: 2px solid currentColor; border-radius: 3px; opacity: .75; }
.size-btn .size-name { grid-area: name; font-weight: 500; }
.size-btn small { grid-area: dim; color: var(--muted-foreground); font-weight: 500; font-size: 12px; }
.export-actions { display: grid; gap: 8px; margin-top: 4px; }
.fine-link { font-size: 12.5px; }

.props { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.props[hidden], [data-prop][hidden] { display: none; }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.items button { width: 100%; text-align: left; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--card); cursor: pointer; font-weight: 500; }
.items button[aria-current="true"] { border-color: #3b82f6; }

/* dialogs of the editor (the dialog itself is in shadcn.css) */
.dev-form { display: grid; gap: 8px; padding: 12px; border: 1px dashed var(--border); border-radius: var(--radius-md); }
.dev-form[hidden] { display: none; }
.premium-list { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.plans { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.plan-card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.plan-card p { margin: 0; }
.plan-price { font-size: 24px; font-weight: 600; letter-spacing: -0.5px; }
.plan-price .fine { font-size: 13px; font-weight: 400; letter-spacing: 0; }
.dev-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-line { font-weight: 600; margin: 0; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.delete-box { border-top: 1px solid var(--border); padding-top: 12px; }
.delete-box summary { cursor: pointer; font-weight: 500; color: var(--destructive); }
.delete-box form { margin-top: 12px; }
.delete-box ul { margin: 0; padding-left: 20px; }

/* The account icon (the avatar look is in shadcn.css): after sign-in it replaces the person icon and the words.
   The word "Account" stays for screen readers. */
.account-btn.signed { padding: 0; width: 40px; height: 40px; border-radius: 50%; border-color: transparent; background: transparent; box-shadow: none; }
.account-btn.signed .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.account-head { display: flex; align-items: center; gap: 12px; }
.account-who { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.account-who strong { font-size: 16px; font-weight: 600; }

/* ---- the avatar menu, the settings dialog and the brand library (E11, E15) ---- */
.account-menu { position: relative; display: flex; align-items: center; }
.menu-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 12px; border-bottom: 1px solid var(--border); }
.menu-who { display: grid; gap: 2px; min-width: 0; justify-items: start; }
.menu-who strong { font-size: 14px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-who .fine { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-who .badge-pill { margin-top: 4px; }
.menu-upgrade { margin-bottom: 0; background: color-mix(in oklab, #be185d 7%, transparent); }
.menu-upgrade .ico { color: #be185d; }
.menu-upgrade .menu-text > span { font-weight: 500; }

.settings-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); height: min(40rem, calc(100dvh - 2rem)); }
.settings-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 12px 12px 24px; border-bottom: 1px solid var(--border); }
.settings-body { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 0; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-right: 1px solid var(--border); background: var(--muted); overflow-y: auto; }
.settings-nav [role="tab"] { display: flex; align-items: center; gap: 8px; width: 100%; height: 36px; padding: 0 10px; border: 1px solid transparent; border-radius: var(--radius-md); background: transparent; color: var(--muted-foreground);
  font: 500 14px/1 var(--font-sans); text-align: left; white-space: nowrap; cursor: pointer; outline: none; }
.settings-nav [role="tab"] > span { flex: 1 1 auto; }
.settings-nav [role="tab"]:hover { color: var(--foreground); }
.settings-nav [role="tab"]:focus-visible { border-color: var(--ring); box-shadow: var(--focus-ring); }
.settings-nav [role="tab"][aria-selected="true"] { background: var(--background); color: var(--foreground); box-shadow: var(--shadow-xs); }
.settings-nav .ico { width: 16px; height: 16px; }
.settings-panes { min-width: 0; overflow-y: auto; padding: 24px; }
.spane { display: grid; gap: 16px; align-content: start; }
.spane[hidden] { display: none; }
.s-head { display: grid; gap: 4px; }
.s-head h3 { font-size: 18px; font-weight: 600; line-height: 1.2; }
.s-card { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); color: var(--card-foreground); }
.s-card h4 { margin: 0; font-size: 14px; font-weight: 600; }
.s-card.danger { border-color: color-mix(in oklab, var(--destructive) 35%, var(--border)); }
.s-card .delete-box { border-top: 0; padding-top: 0; }
.s-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.s-grow { flex: 1 1 auto; min-width: 0; display: grid; gap: 4px; }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.check-list li { display: flex; align-items: center; gap: 8px; }
.check-list li::before { content: ""; flex: none; width: 16px; height: 16px; background: var(--success);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat; }
.badge-pill { text-transform: none; letter-spacing: 0; }
.badge-pill .ico { width: 12px; height: 12px; opacity: 1; }
.badge-pill.premium { background: #be185d; color: #fff; }

/* My backgrounds in the Background tab */
.my-bg { display: grid; gap: 8px; }
.my-bg-body { display: grid; gap: 8px; }
.sw img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sw.add { display: grid; place-items: center; border-style: dashed; color: var(--muted-foreground); }
.sw.add:hover { color: var(--foreground); }
.sw.add .ico { width: 20px; height: 20px; }
.sw.busy { opacity: .6; cursor: progress; }
.lock-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.lock-tiles span { aspect-ratio: 16 / 10; border-radius: var(--radius-md); border: 1px solid var(--border); background: linear-gradient(135deg, color-mix(in oklab, var(--muted-foreground) 25%, transparent), color-mix(in oklab, var(--muted-foreground) 8%, transparent)); display: grid; place-items: center; color: var(--muted-foreground); }
.lock-tiles .ico { width: 16px; height: 16px; }
.my-bg-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.linklike { appearance: none; border: 0; background: none; padding: 0; color: var(--foreground); font: 500 12.5px/1.4 var(--font-sans); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linklike:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--radius-sm); outline: none; }

/* the brand library in the settings dialog */
#brand-manager { display: grid; gap: 16px; }
.brand-usage { display: grid; gap: 6px; }
.brand-usage-line { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand-upload { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 20px 16px; border: 2px dashed var(--border); border-radius: var(--radius-xl); transition: background .15s, border-color .15s; }
.brand-upload.over { border-color: var(--primary); background: color-mix(in oklab, var(--primary) 6%, transparent); }
.brand-upload .ico { width: 24px; height: 24px; color: var(--muted-foreground); }
.brand-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.brand-card { display: grid; grid-template-rows: auto 1fr auto; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--card); box-shadow: var(--shadow-xs); }
.brand-thumb { aspect-ratio: 16 / 10; background: var(--muted); }
.brand-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-meta { display: grid; gap: 2px; padding: 8px 10px 4px; min-width: 0; }
.brand-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-actions { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 6px 8px; }
.brand-actions .btn { height: 30px; padding: 0 10px; font-size: 13px; }
.brand-confirm { display: grid; gap: 6px; padding: 4px 10px 10px; }
.brand-rename { display: grid; gap: 6px; padding: 8px 10px 4px; }
.brand-rename input { height: 32px; }
.brand-empty { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 24px 16px; border: 1px dashed var(--border); border-radius: var(--radius-xl); }

@media (max-width: 720px) {
  .dialog.dialog-xl { width: calc(100% - 1rem); max-width: none; }
  .settings-shell { height: calc(100dvh - 1rem); }
  .settings-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .settings-nav { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px 12px; }
  .settings-nav [role="tab"] { width: auto; }
  .settings-panes { padding: 16px; }
}

/* tablet and phone: the settings become a sheet at the bottom; controls are 40 px high for the thumb */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .stage { padding: 12px; }
  .panel { border-left: 0; border-top: 1px solid var(--border); height: 46dvh; padding-bottom: env(safe-area-inset-bottom); }
  .drop-card h2 { font-size: 22px; }
  .topbar { padding: 8px 12px; }
  #export-top span, #new { display: none; }
  #export-top { padding: 0 12px; }
  .frames { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sizes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .toast { bottom: calc(46dvh + 12px); }
  .btn, .icon-btn, .seg button, input[type="text"], input[type="email"], select { height: 40px; }
  .icon-btn { width: 40px; }
}
@media (max-width: 480px) {
  .plans { grid-template-columns: minmax(0, 1fr); }
  .account-btn .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .account-btn { padding: 0; width: 40px; }
  .brand { font-size: 15px; }
  .frames { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sizes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .swatches { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
