@font-face {
  font-family: "AppleNeo";
  src: local("Apple SD Gothic Neo"),
       url("./AppleSDGothicNeo.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: "AppleNeo", sans-serif;
  background: #ededed;
  color: #242424;
  --lime: #85a2c1;
  --lime-soft: rgba(133, 162, 193, .18);
  --line: rgba(36, 36, 36, .12);
  --line-strong: rgba(36, 36, 36, .22);
  --muted: #6f6f6f;
  --panel: #f8f8f8;
  --control-width: 80.5%;
  --control-height: 40px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: #ededed; color: #242424; }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

.editor-shell { display: grid; grid-template-columns: minmax(344px, 4fr) minmax(440px, 6fr); min-height: 100vh; }
.control-panel { padding: clamp(14px, 2vw, 29px) clamp(18px, 3vw, 44px) clamp(28px, 4vw, 58px) clamp(36px, 6vw, 88px); border-right: 1px solid rgba(36,36,36,.08); background: #ededed; }
.eyebrow { margin: 0 0 12px; color: var(--lime); font-size: 11px; letter-spacing: .18em; }
.panel-card { max-width: 590px; padding: 24px 0; border: 0; }
.section-heading { display: grid; grid-template-columns: 32px 1fr; gap: 14px; margin-bottom: 8px; }
.section-heading > span { color: var(--lime); font-size: 11px; }
.section-heading h2 { margin: -3px 0 4px; font-size: 18px; font-weight: 400; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.indented { margin-left: 46px; }
.controls-stack { display: grid; gap: 14px; }
.field-grid { display: grid; grid-template-columns: 6fr 2.5fr; column-gap: 15%; width: var(--control-width); }
.text-field { display: grid; gap: 8px; width: 100%; color: var(--muted); font-size: 13.2px; }
.text-field input { width: 100%; height: var(--control-height); min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--panel); color: #242424; outline: none; }
.text-field input:focus { border-color: var(--lime); box-shadow: 0 0 0 3px var(--lime-soft); }

.upload-field { position: relative; display: grid; grid-template-columns: 42px 1fr; align-items: center; gap: 12px; width: var(--control-width); min-height: 78px; border: 1px dashed var(--line-strong); border-radius: 14px; padding: 14px; background: #f8f8f8; cursor: pointer; transition: border-color .18s, background .18s; }
.upload-field:hover { border-color: var(--lime); background: var(--lime-soft); }
.upload-field input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.upload-field > span:last-child { display: grid; gap: 4px; min-width: 0; }
.upload-field strong { font-size: 13px; font-weight: 400; }
.upload-field small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-plus { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--lime); color: #fff; font-size: 22px; }
.secondary-button, .apply-button { height: var(--control-height); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--panel); color: #242424; font-size: 14px; }
.secondary-button:hover:not(:disabled) { border-color: var(--line-strong); background: #fff; }
.secondary-button:disabled { cursor: not-allowed; opacity: .38; }
.apply-button { border-color: var(--lime); background: var(--lime); color: #fff; }
#recropButton { width: var(--control-width); border-color: var(--lime); background: var(--lime); color: #fff; }

.range-field { display: grid; gap: 8px; width: var(--control-width); }
.range-field > span { display: flex; justify-content: space-between; color: var(--muted); font-size: 13.2px; }
.range-field output { color: #a8a8a8; }
input[type="range"] { width: 100%; height: 3px; margin: 7px 0; border: 0; border-radius: 99px; padding: 0; appearance: none; background: linear-gradient(to right, var(--lime) 0 var(--range-progress, 39%), #d0d0d0 var(--range-progress, 39%) 100%); }
input[type="range"]::-webkit-slider-thumb { width: 17px; height: 17px; border: 4px solid #ededed; border-radius: 50%; appearance: none; background: var(--lime); box-shadow: 0 0 0 1px rgba(36,36,36,.16); }
input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border: 4px solid #ededed; border-radius: 50%; background: var(--lime); }

.option-field { width: var(--control-width); min-width: 220px; margin: 0; border: 0; padding: 0; }
.option-field legend { margin-bottom: 8px; color: var(--muted); font-size: 13.2px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; height: var(--control-height); padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #f8f8f8; }
.segment { border: 0; border-radius: 7px; padding: 0 8px; background: transparent; color: var(--muted); font-size: 11px; }
.segment.active { background: var(--lime); color: #fff; }
.switch-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; width: var(--control-width); min-width: 220px; min-height: var(--control-height); cursor: pointer; }
.switch-row > span { display: grid; gap: 4px; }
.switch-row strong { font-size: 13px; font-weight: 400; }
.switch-row small { color: var(--muted); font-size: 10px; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row i { position: relative; width: 46px; height: 26px; border-radius: 99px; background: #c9c9c9; transition: background .18s; }
.switch-row i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 4px rgba(36,36,36,.18); }
.switch-row input:checked + i { background: var(--lime); }
.switch-row input:checked + i::after { transform: translateX(20px); background: #fff; }
.battery-field { padding-top: 2px; }

.panel-card:last-of-type { padding-bottom: 12px; }
.save-actions { max-width: none; margin-left: 46px; padding-top: 12px; border: 0; }
.save-button-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: var(--control-width); }
.save-button { width: 100%; height: var(--control-height); border: 0; border-radius: 10px; padding: 0 12px; background: var(--lime); color: #fff; font-size: 14px; }
.save-button:hover { background: #7594b5; }

.preview-stage { position: sticky; top: 0; height: 100vh; display: grid; place-items: center; align-content: center; min-height: 100vh; padding: 34px; background: #f2f2f2; overflow: hidden; user-select: none; }
.preview-stage::before { content: none; }
.preview-head { position: absolute; top: 28px; left: 34px; right: 34px; z-index: 1; }
.preview-head h2 { margin: 0; font-size: 16px; font-weight: 400; }
.phone-shell { position: relative; width: min(330px, calc((100vh - 126px) * 9 / 19.5)); padding: 7px; border: 1px solid #000; border-radius: 48px; background: #000; box-shadow: 0 26px 70px rgba(36,36,36,.2); pointer-events: none; }
.phone-shell::before { content: ""; position: absolute; top: 86px; left: -4px; width: 3px; height: 68px; border-radius: 4px 0 0 4px; background: #111; box-shadow: 0 90px #111; }
#previewCanvas { display: block; width: 100%; aspect-ratio: 9 / 19.5; border-radius: 41px; background: #a8a8a8; pointer-events: none; user-select: none; -webkit-user-drag: none; }

.crop-dialog { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; border: 0; padding: 0; background: transparent; color: #242424; overflow: hidden; }
.crop-dialog[open] { display: grid; place-items: center; padding: 12px; }
.crop-dialog::backdrop { background: rgba(36,36,36,.46); backdrop-filter: blur(10px); }
.crop-card { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 10px; width: min(440px, calc(100vw - 24px)); height: min(780px, calc(100dvh - 24px)); max-height: calc(100dvh - 24px); margin: 0; border: 1px solid var(--line-strong); border-radius: 18px; padding: 16px; background: #ededed; box-shadow: 0 24px 80px rgba(36,36,36,.28); overflow: hidden; }
.crop-header { display: flex; align-items: flex-start; justify-content: space-between; }
.crop-header { align-items: center; }
.crop-header h2 { margin: 0; font-size: 20px; font-weight: 400; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: #f8f8f8; color: #242424; font-size: 21px; }
.crop-workspace { display: grid; grid-template-columns: minmax(0, 1fr); justify-content: center; align-items: center; min-width: 0; min-height: 0; border-radius: 14px; padding: 10px; background: #dedede; overflow: hidden; }
.crop-canvas-shell { display: grid; place-items: center; min-width: 0; min-height: 0; width: 100%; height: 100%; overflow: hidden; }
#cropCanvas { display: block; flex: none; width: auto; height: auto; max-width: none; max-height: none; border-radius: 12px; background: #a8a8a8; box-shadow: 0 10px 28px rgba(36,36,36,.18); cursor: grab; touch-action: none; }
#cropCanvas.dragging { cursor: grabbing; }
.crop-actions { display: flex; justify-content: flex-end; gap: 8px; }
.crop-actions button { min-width: 124px; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 100; border: 1px solid var(--line-strong); border-radius: 999px; padding: 11px 18px; background: #f4f4f0; color: #111; font-size: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.32); opacity: 0; pointer-events: none; transform: translate(-50%, 14px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 920px) {
  .editor-shell { grid-template-columns: 1fr; }
  .control-panel { padding: 22px 22px 44px; border-right: 0; }
  .preview-stage { position: relative; top: 0; height: auto; min-height: 820px; }
  .preview-head { top: 24px; left: 22px; right: 22px; }
}

@media (max-width: 620px) {
  :root { --control-width: 100%; }
  .control-panel { padding-top: 19px; }
  .indented { margin-left: 0; }
  .field-grid { grid-template-columns: 1fr; gap: 14px; }
  .preview-stage { min-height: 760px; padding: 84px 18px 30px; }
  .phone-shell { width: min(300px, calc(100vw - 54px)); }
  .crop-dialog[open] { padding: 6px; }
  .crop-card { width: calc(100vw - 12px); height: calc(100dvh - 12px); max-height: calc(100dvh - 12px); border-radius: 16px; padding: 12px; }
  .crop-workspace { padding: 8px; }
  .crop-actions button { flex: 1; min-width: 0; }
  .option-field { width: 100%; min-width: 0; }
  .switch-row { width: 100%; min-width: 0; }
  .save-actions { max-width: none; margin-left: 0; }
}

@media (max-height: 760px) {
  .crop-dialog[open] { padding: 6px; }
  .crop-card { height: calc(100dvh - 12px); max-height: calc(100dvh - 12px); padding: 12px; }
  .crop-workspace { padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
