:root {
  color-scheme: dark;
  --bg: #070b12;
  --panel: #111722;
  --panel-raised: #171f2d;
  --panel-soft: #0d131d;
  --line: #2b3545;
  --line-strong: #405069;
  --text: #f7f9fc;
  --muted: #9caabd;
  --green: #53e6a3;
  --green-dark: #0c8f5a;
  --blue: #6cb6ff;
  --yellow: #ffc45c;
  --red: #ff7a8a;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(circle at 12% 0%, rgba(83, 230, 163, .11), transparent 28rem),
    radial-gradient(circle at 100% 10%, rgba(108, 182, 255, .10), transparent 34rem),
    var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { color: inherit; }
a { color: var(--blue); }
.hidden { display: none !important; }

.preset-app {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 14px 0 28px;
}

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(64, 80, 105, .55);
}
.topbar > div { display: flex; align-items: center; gap: 10px; }
.topbar > div > div:last-child { display: grid; line-height: 1.1; }
.topbar strong { font-size: 17px; letter-spacing: -.025em; }
.topbar span { margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid rgba(83, 230, 163, .55); border-radius: 10px;
  background: linear-gradient(145deg, rgba(83, 230, 163, .2), rgba(108, 182, 255, .12));
  color: var(--green); font-size: 12px; font-weight: 950; letter-spacing: -.03em;
}

.connection-card {
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(17, 23, 34, .82);
}
.connection-card > div { display: grid; grid-template-columns: auto minmax(140px, auto) 1fr; align-items: center; gap: 12px; }
.connection-card strong { font-size: 13px; }
.connection-card > div > span:last-child { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.status-pill {
  display: inline-flex; align-items: center; width: fit-content;
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 5px 9px; background: var(--panel-soft); color: var(--muted);
  font-size: 11px; font-weight: 900;
}
.status-pill::before { content: ""; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent); }
.status-pill.ok { border-color: rgba(83, 230, 163, .45); color: var(--green); }
.status-pill.error { border-color: rgba(255, 122, 138, .45); color: var(--red); }
.status-pill.checking { color: var(--yellow); }

.creator-layout { display: grid; gap: 12px; }
.shot-save-layout { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(0, 2fr); align-items: start; gap: 7px; }
.preview-panel, .settings-panel, .library-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(23, 31, 45, .97), rgba(14, 20, 30, .97));
  box-shadow: 0 18px 60px rgba(0, 0, 0, .22);
}
.preview-panel { padding: 16px; }
.settings-panel { padding: 9px; }
.library-panel { margin-top: 0; padding: 9px; }
.save-panel { margin-top: 0; }
.save-panel summary { cursor: pointer; list-style: none; }
.save-panel summary::-webkit-details-marker { display: none; }
.save-panel summary::after { content: "＋"; color: var(--green); font-size: 20px; font-weight: 400; }
.save-panel[open] summary::after { content: "−"; }
.expand-hint { margin-left: auto; color: var(--muted); font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.panel-heading, .library-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading > div, .library-heading > div { display: flex; align-items: center; gap: 10px; }
.panel-heading h1, .panel-heading h2, .library-heading h2 { margin: 0; font-size: 16px; line-height: 1.15; letter-spacing: -.025em; }
.panel-heading p, .library-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.panel-heading.compact { margin-bottom: 10px; }
.step-number {
  flex: 0 0 auto; width: 28px; height: 28px; display: grid; place-items: center;
  border: 1px solid rgba(83, 230, 163, .42); border-radius: 9px;
  background: rgba(83, 230, 163, .09); color: var(--green); font-size: 12px; font-weight: 950;
}

.source-choice { display: grid; gap: 4px; min-width: 180px; color: var(--muted); font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.source-choice select { padding: 7px 9px; }

.preview-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, .025) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, .025) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, .025) 25%, #0b111b 25%, #0b111b 75%, rgba(255, 255, 255, .025) 75%);
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
  user-select: none;
  touch-action: none;
}
.preview-stage > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #030508; pointer-events: none; }
.preview-empty { position: absolute; inset: 0; display: grid; place-content: center; gap: 6px; padding: 28px; color: var(--muted); text-align: center; }
.preview-empty strong { color: #d9e1ec; font-size: 16px; }
.preview-empty span { max-width: 34rem; font-size: 12px; }
.master-frame {
  position: absolute;
  border: 1px dashed rgba(108, 182, 255, .75);
  box-shadow: 0 0 0 9999px rgba(2, 5, 9, .16);
  pointer-events: none;
}
.master-frame::before {
  content: "MASTER"; position: absolute; left: 5px; top: 5px;
  padding: 2px 5px; border-radius: 5px; background: rgba(5, 10, 17, .75);
  color: var(--blue); font-size: 8px; font-weight: 950; letter-spacing: .11em;
}
.crop-frame {
  position: absolute;
  border: 2px solid var(--green);
  border-radius: 8px;
  background: rgba(83, 230, 163, .05);
  box-shadow: 0 0 0 1px rgba(5, 10, 17, .55), 0 0 25px rgba(83, 230, 163, .18);
  cursor: grab;
  pointer-events: auto;
}
.crop-frame:active { cursor: grabbing; }
.crop-frame:focus-visible { outline: 3px solid rgba(108, 182, 255, .85); outline-offset: 3px; }
.crop-frame::before, .crop-frame::after { content: ""; position: absolute; background: rgba(255, 255, 255, .22); pointer-events: none; }
.crop-frame::before { left: 50%; top: 0; width: 1px; height: 100%; }
.crop-frame::after { left: 0; top: 50%; width: 100%; height: 1px; }
.crop-frame > span {
  position: absolute; left: 50%; top: 50%; z-index: 2; transform: translate(-50%, -50%);
  max-width: calc(100% - 16px); overflow: hidden; padding: 4px 7px;
  border-radius: 999px; background: rgba(5, 10, 17, .84); color: #dcfff0;
  font-size: 10px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap;
  pointer-events: none;
}
.resize-handle {
  position: absolute; right: -7px; bottom: -7px; z-index: 3;
  width: 16px; height: 16px; padding: 0;
  border: 2px solid #05100c; border-radius: 5px;
  background: var(--green); cursor: nwse-resize;
}

.reference-action { display: grid; grid-template-columns: minmax(210px, auto) 1fr; gap: 10px; align-items: center; margin-top: 12px; }
.reference-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.reference-action span { color: var(--muted); font-size: 10px; line-height: 1.4; }
.reference-button {
  min-height: 43px; border: 0; border-radius: 11px; padding: 10px 13px;
  background: var(--green); color: #052317; box-shadow: 0 10px 28px rgba(83, 230, 163, .16);
  font-size: 12px; font-weight: 950; cursor: pointer;
}
.reference-button:hover { background: #7af0b9; }
.master-frame-button { background: #2878e8; border: 1px solid #61a6ff; color: #ffffff; box-shadow: 0 10px 28px rgba(40, 120, 232, .34); }
.master-frame-button:hover { background: #4692ff; }
.reference-button:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.reference-status { min-height: 0; margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.reference-status:empty { display: none; }
.reference-status.ok { color: #cffff0; }
.reference-status.error { padding: 7px 9px; border-left: 3px solid var(--red); border-radius: 7px; background: rgba(7, 11, 18, .46); color: #ffd8d8; }
.preview-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.file-button, .secondary-button, .quiet-button, .text-button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 8px 11px; background: var(--panel-raised); color: #e6edf7;
  font-size: 12px; font-weight: 850; cursor: pointer;
}
.file-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.secondary-button:hover, .quiet-button:hover, .file-button:hover { border-color: var(--blue); }
.secondary-button:disabled, .quiet-button:disabled { opacity: .45; cursor: not-allowed; }
.quiet-button { min-height: 32px; padding: 6px 10px; background: transparent; }
.privacy-note { margin: 8px 0 0; color: var(--muted); font-size: 10px; }

.field { display: grid; gap: 6px; margin-top: 12px; color: #d7e0eb; font-size: 11px; font-weight: 850; }
input, select {
  width: 100%; min-height: 39px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 8px 10px; background: #0b111a; color: var(--text);
}
input:focus, select:focus { outline: 2px solid rgba(108, 182, 255, .65); outline-offset: 2px; }
.behavior-field { margin: 14px 0 0; padding: 0; border: 0; }
.behavior-field legend { margin-bottom: 6px; color: #d7e0eb; font-size: 11px; font-weight: 850; }
.behavior-field { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.behavior-field legend { grid-column: 1 / -1; }
.behavior-field label { position: relative; }
.behavior-field input { position: absolute; opacity: 0; }
.behavior-field label span { display: grid; min-height: 60px; align-content: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-soft); cursor: pointer; }
.behavior-field label strong { font-size: 12px; }
.behavior-field label small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.behavior-field input:checked + span { border-color: rgba(83, 230, 163, .68); background: rgba(83, 230, 163, .09); box-shadow: 0 0 0 1px rgba(83, 230, 163, .14) inset; }
.behavior-field input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.frame-readout { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin: 14px 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(7, 11, 18, .42); }
.frame-readout span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.frame-readout strong { font-size: 11px; }
.primary-button, .apply-button {
  width: 100%; min-height: 43px; border: 0; border-radius: 11px;
  padding: 10px 13px; font-weight: 950; cursor: pointer;
}
.primary-button { background: var(--green); color: #052317; box-shadow: 0 10px 28px rgba(83, 230, 163, .16); }
.apply-button { margin-top: 8px; border: 1px solid rgba(108, 182, 255, .55); background: rgba(108, 182, 255, .12); color: #d9ecff; }
.primary-button:hover { background: #7af0b9; }
.apply-button:hover:not(:disabled) { background: rgba(108, 182, 255, .22); }
.primary-button:disabled, .apply-button:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.secondary-button.full { width: 100%; margin-top: 8px; }
.text-button { width: 100%; min-height: 32px; margin-top: 7px; border-color: transparent; background: transparent; color: var(--muted); font-size: 10px; }
.text-button:hover { color: var(--blue); }
.shortcut-row { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; }
.shortcut-row button { margin: 0; min-height: 36px; }
.shortcut-row .text-button { width: auto; padding: 0 8px; }
.recording { border-color: var(--orange) !important; color: var(--orange) !important; }
.save-indicator { min-height: 18px; margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.save-indicator.ok { color: var(--green); font-weight: 800; }

.status-message { min-height: 38px; margin: 10px 0 0; padding: 9px 10px; border-left: 3px solid var(--line-strong); border-radius: 7px; background: rgba(7, 11, 18, .46); color: var(--muted); font-size: 11px; }
.status-message.ok { border-color: var(--green); color: #cffff0; }
.status-message.error { border-color: var(--red); color: #ffd5da; }

.library-heading { margin-bottom: 9px; }
.count-pill { border: 1px solid var(--line); border-radius: 999px; padding: 5px 8px; color: var(--muted); font-size: 10px; font-weight: 900; }
.preset-library { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.preset-tile {
  display: grid; grid-template-columns: 1fr auto; align-items: stretch; gap: 8px;
  min-width: 0; border: 1px solid var(--line); border-radius: 11px;
  padding: 8px; background: rgba(11, 17, 26, .72); color: var(--text);
}
.preset-tile:hover { border-color: var(--blue); }
.preset-tile.active { border-color: var(--green); background: rgba(83, 230, 163, .07); }
.preset-load { display: grid; grid-template-columns: 1fr auto; align-items: start; column-gap: 9px; min-width: 0; border: 0; padding: 2px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.preset-copy { display: grid; justify-items: start; min-width: 0; }
.preset-number { min-width: 24px; min-height: 20px; margin-top: 7px; padding: 2px 7px; display: grid; place-items: center; border: 1px solid rgba(106, 169, 255, .28); border-radius: 6px; background: rgba(106, 169, 255, .045); color: var(--blue); font-size: 10px; font-weight: 900; }
.preset-tile strong, .preset-tile small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-name { max-width: 100%; font-size: 12px; }
.preset-tile small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.tile-action { color: var(--green); font-size: 9px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
.tile-apply { align-self: center; border: 1px solid rgba(83, 230, 163, .45); border-radius: 8px; padding: 6px 8px; background: rgba(83, 230, 163, .1); color: var(--green); font-size: 10px; font-weight: 900; cursor: pointer; }
.tile-apply:hover { background: var(--green); color: #052317; }
.library-empty { grid-column: 1 / -1; padding: 18px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; font-size: 11px; }
.quick-heading { display: grid; gap: 3px; margin: 8px 0 5px; }
.quick-heading strong { font-size: 12px; }
.quick-heading span { color: var(--muted); font-size: 10px; }
.quick-presets { display: grid; grid-template-columns: 1fr; gap: 4px; }
.quick-preset { display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 6px 7px; background: var(--panel-soft); color: var(--text); text-align: left; cursor: pointer; }
.quick-preset:hover { border-color: var(--green); background: rgba(83, 230, 163, .1); }
.quick-preset kbd { display: grid; place-items: center; flex: 0 0 auto; width: 21px; height: 21px; border-radius: 6px; background: var(--green); color: #052317; font-size: 10px; font-weight: 950; }
.quick-preset span { overflow: hidden; font-size: 10px; font-weight: 850; text-overflow: ellipsis; white-space: nowrap; }

footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; padding: 16px 6px 0; color: #69778a; font-size: 9px; font-weight: 800; letter-spacing: .04em; }
footer a { color: #8292a8; }

.public-page { width: min(820px, calc(100vw - 28px)); margin: 0 auto; padding: 22px 0 36px; }
.public-page nav { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px; }
.public-page nav a { border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; background: var(--panel-soft); color: #dfe7f2; font-size: 11px; font-weight: 850; text-decoration: none; }
.public-page main { border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(22px, 5vw, 48px); background: linear-gradient(145deg, rgba(23, 31, 45, .97), rgba(14, 20, 30, .97)); }
.public-page main > span { color: var(--green); font-size: 10px; font-weight: 950; letter-spacing: .12em; text-transform: uppercase; }
.public-page h1 { margin: 7px 0 20px; font-size: clamp(30px, 7vw, 54px); line-height: .98; letter-spacing: -.055em; }
.public-page h2 { margin: 24px 0 8px; font-size: 16px; }
.public-page p, .public-page li { color: #c7d1df; }
.public-page li { margin: 7px 0; }

@media (max-width: 820px) {
  .shot-save-layout { grid-template-columns: 1fr; }
  .preset-library { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .connection-card > div { grid-template-columns: auto 1fr; }
  .connection-card > div > span:last-child { grid-column: 1 / -1; white-space: normal; }
}
@media (max-width: 520px) {
  .preset-app { width: min(100% - 16px, 1180px); padding-top: 8px; }
  .panel-heading { align-items: start; }
  .source-choice { min-width: 0; }
  .preset-library { grid-template-columns: 1fr; }
  .reference-action { grid-template-columns: 1fr; }
  .reference-button { width: 100%; }
  .preview-tools { display: grid; }
  .connection-card > div { grid-template-columns: 1fr; }
  .preview-panel, .settings-panel, .library-panel { border-radius: 13px; padding: 12px; }
}
