:root {
  color-scheme: light;
  --ink: #111217;
  --muted: #686c75;
  --hairline: rgba(15, 23, 42, 0.12);
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #ffffff;
  --control: rgba(242, 244, 247, 0.92);
  --blue: #007aff;
  --blue-pressed: #0063ce;
  --shadow-soft: 0 24px 70px rgba(32, 44, 67, 0.16);
  --shadow-phone: 0 30px 80px rgba(23, 28, 38, 0.3);
  --phone-w: 350px;
  --phone-h: 720px;
  --phone-ratio: 2.057;
  --wallpaper-url: linear-gradient(145deg, #d8e6f8, #f8efe2 45%, #c7d7ef);
  --stage-blur: 28px;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(circle at 14% 12%, rgba(255, 255, 255, 0.92), transparent 30%),
    radial-gradient(circle at 88% 18%, rgba(179, 203, 232, 0.82), transparent 34%),
    linear-gradient(135deg, #eef3f9 0%, #f8f1ea 52%, #dfe8f3 100%);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.ambient {
  position: fixed;
  inset: -7%;
  z-index: 0;
  background-image: var(--wallpaper-url);
  background-position: center;
  background-size: cover;
  filter: blur(var(--stage-blur)) saturate(1.04);
  opacity: 0.5;
  pointer-events: none;
  transform: scale(1.05);
  transition: background-image 220ms ease, filter 220ms ease, opacity 220ms ease;
}

.ambient::after {
  position: absolute;
  inset: 0;
  content: "";
  background: rgba(247, 249, 252, 0.58);
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(360px, 1fr) minmax(240px, 300px);
  gap: 18px;
  width: min(1480px, calc(100% - 40px));
  min-height: calc(100vh - 40px);
  margin: 20px auto;
}

.library-panel,
.control-panel,
.preview-stage {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(24px) saturate(1.18);
  -webkit-backdrop-filter: blur(24px) saturate(1.18);
}

.library-panel,
.control-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px;
}

.preview-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  padding: 18px;
  isolation: isolate;
}

.preview-stage::before {
  position: absolute;
  inset: -42px;
  z-index: 0;
  background-image: var(--wallpaper-url);
  background-position: center;
  background-size: cover;
  content: "";
  filter: blur(var(--stage-blur)) saturate(1.08);
  opacity: 0.62;
  transform: scale(1.05);
  transition: background-image 220ms ease, filter 220ms ease;
}

.preview-stage::after {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(255, 255, 255, 0.34);
  content: "";
}

.preview-stage > * {
  position: relative;
  z-index: 1;
}

.panel-heading,
.preview-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-heading.compact {
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.05;
}

h2 {
  font-size: 22px;
  line-height: 1.1;
}

.icon-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--control);
  transition: background 160ms ease, transform 160ms ease, color 160ms ease;
}

.icon-button {
  width: 38px;
}

.text-button {
  padding: 0 14px;
  font-size: 14px;
  font-weight: 650;
}

.text-button.primary {
  color: #fff;
  background: var(--blue);
}

.icon-button:hover,
.text-button:hover {
  transform: translateY(-1px);
}

.text-button.primary:active {
  background: var(--blue-pressed);
}

.trash-icon,
.upload-mark,
.empty-glyph {
  display: inline-block;
  position: relative;
}

.trash-icon {
  width: 15px;
  height: 17px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 2px 2px 4px 4px;
}

.trash-icon::before {
  position: absolute;
  left: -3px;
  top: -5px;
  width: 19px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  content: "";
}

.trash-icon::after {
  position: absolute;
  left: 4px;
  top: -8px;
  width: 7px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  content: "";
}

.upload-zone {
  display: grid;
  place-items: center;
  min-height: 170px;
  margin-top: 20px;
  padding: 18px;
  border: 1px dashed rgba(15, 23, 42, 0.22);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.45);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
  cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragging {
  border-color: rgba(0, 122, 255, 0.58);
  background: rgba(255, 255, 255, 0.7);
  transform: translateY(-1px);
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.upload-zone strong {
  margin-top: 12px;
  color: var(--ink);
  font-size: 18px;
}

.upload-zone span:last-child {
  margin-top: 6px;
  font-size: 13px;
}

.upload-mark {
  width: 42px;
  height: 42px;
  border: 2px solid rgba(0, 122, 255, 0.84);
  border-radius: 50%;
}

.upload-mark::before,
.upload-mark::after {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--blue);
  content: "";
  transform: translate(-50%, -50%);
}

.upload-mark::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.library-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.library-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb-list {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.thumb-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
  transition: border-color 160ms ease, background 160ms ease;
}

.thumb-item.selected {
  border-color: rgba(0, 122, 255, 0.45);
  background: rgba(240, 247, 255, 0.86);
}

.thumb-button {
  display: block;
  width: 56px;
  height: 74px;
  padding: 0;
  overflow: hidden;
  border-radius: 7px;
  background: #d9dee7;
}

.thumb-button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-info {
  min-width: 0;
}

.thumb-name {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb-size {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.thumb-tools {
  display: grid;
  grid-template-columns: repeat(2, 28px);
  gap: 5px;
}

.mini-button {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--muted);
  background: rgba(236, 239, 244, 0.9);
}

.mini-button:hover {
  color: var(--ink);
  background: #fff;
}

.preview-topbar {
  width: 100%;
}

.preview-actions {
  display: flex;
  gap: 8px;
}

.phone-wrap {
  display: grid;
  flex: 1;
  width: 100%;
  min-height: 760px;
  place-items: center;
  padding: 20px 0 6px;
}

.phone-frame {
  position: relative;
  width: var(--phone-w);
  height: var(--phone-h);
  padding: 10px;
  border-radius: 54px;
  background: linear-gradient(145deg, #f9fafc, #bfc5cf 42%, #f7f8fb);
  box-shadow: var(--shadow-phone), inset 0 0 0 1px rgba(255, 255, 255, 0.72);
  transition: width 180ms ease, height 180ms ease;
}

.phone-frame::before {
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 49px;
  content: "";
  pointer-events: none;
}

.phone-screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 44px;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.68), transparent 25%),
    linear-gradient(155deg, #b9cff0, #eef1f7 58%, #f3dcc1);
  isolation: isolate;
}

.wallpaper-image {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  transform: none;
  transform-origin: center;
  opacity: 0;
  transition:
    opacity 180ms ease,
    left 180ms ease,
    top 180ms ease,
    width 180ms ease,
    height 180ms ease,
    object-position 180ms ease;
}

.wallpaper-image.ready {
  opacity: 1;
}

.dynamic-island {
  position: absolute;
  left: 50%;
  top: 24px;
  z-index: 5;
  width: 94px;
  height: 27px;
  border-radius: 99px;
  background: #0b0b0c;
  transform: translateX(-50%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.lock-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  color: #fff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 19px 30px 0;
  font-size: 14px;
  font-weight: 700;
}

.status-icons {
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-symbol {
  display: block;
  color: rgba(255, 255, 255, 0.95);
  fill: currentColor;
  filter: drop-shadow(0 1px 8px rgba(0, 0, 0, 0.12));
}

.cellular-symbol {
  width: 20px;
  height: 14px;
}

.wifi-symbol {
  width: 18px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.wifi-symbol circle {
  fill: currentColor;
  stroke: none;
}

.battery-symbol {
  width: 25px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.battery-fill {
  fill: currentColor;
  stroke: none;
}

.battery-cap {
  stroke-linecap: round;
}

.date-line {
  margin-top: 88px;
  font-size: clamp(19px, calc(var(--phone-w) * 0.06), 23px);
  font-weight: 680;
  text-align: center;
}

.time-line {
  margin-top: 10px;
  font-size: clamp(88px, calc(var(--phone-w) * 0.34), 126px);
  font-weight: 760;
  line-height: 0.86;
  text-align: center;
  letter-spacing: 0;
  transform-origin: center top;
  transition: font-size 160ms ease, transform 160ms ease;
  white-space: nowrap;
}

.widget-line {
  position: absolute;
  left: 42px;
  bottom: 145px;
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 6px;
  row-gap: 2px;
  align-items: center;
  font-size: 15px;
  font-weight: 700;
}

.widget-line span:last-child {
  grid-column: 1 / -1;
}

.widget-battery {
  width: 13px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.widget-battery rect:last-child {
  fill: currentColor;
  stroke: none;
  opacity: 0.92;
}

.signature {
  position: absolute;
  right: 46px;
  bottom: 130px;
  font-family: "Snell Roundhand", "Apple Chancery", cursive;
  font-size: 32px;
  font-weight: 500;
  transform: rotate(-9deg);
  opacity: 0.92;
}

.quick-actions {
  position: absolute;
  left: 38px;
  right: 38px;
  bottom: 56px;
  display: flex;
  justify-content: space-between;
}

.round-action {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(28, 32, 38, 0.34);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    0 5px 18px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
}

.lock-action-symbol {
  width: 28px;
  height: 28px;
  fill: currentColor;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.torch-symbol {
  stroke-width: 1.5;
}

.camera-symbol {
  fill: none;
  stroke-width: 2.3;
}

.camera-symbol path {
  fill: currentColor;
  stroke: none;
}

.camera-symbol circle {
  fill: rgba(28, 32, 38, 0.36);
}

.home-indicator {
  position: absolute;
  left: 50%;
  bottom: 16px;
  width: 132px;
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.9);
  transform: translateX(-50%);
}

.empty-state {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 36px;
  color: rgba(255, 255, 255, 0.96);
  text-align: center;
  text-shadow: 0 2px 18px rgba(40, 50, 72, 0.22);
}

.empty-state strong {
  font-size: 20px;
}

.empty-state span:last-child {
  font-size: 13px;
  font-weight: 650;
}

.empty-glyph {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
}

.empty-glyph::before {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 9px;
  height: 20px;
  border-radius: 8px 8px 5px 5px;
  background: rgba(255, 255, 255, 0.72);
  clip-path: polygon(0 100%, 34% 36%, 52% 68%, 68% 42%, 100% 100%);
  content: "";
}

.control-group {
  display: grid;
  gap: 10px;
  padding: 0;
}

.control-group.control-disabled {
  opacity: 0.55;
}

.control-group.control-disabled input {
  cursor: not-allowed;
}

.control-group label,
.label-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.settings-sections {
  display: grid;
  gap: 18px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.settings-section {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}

.settings-section h3 {
  margin: 0;
  color: #2c313a;
  font-size: 14px;
  font-weight: 760;
  letter-spacing: 0;
}

.settings-section .control-group + .control-group {
  padding-top: 4px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

select {
  width: 100%;
  min-height: 40px;
  padding: 0 34px 0 12px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-solid);
}

.field-grid {
  display: grid;
  gap: 8px;
}

.field-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.field-row input {
  width: 100%;
  min-width: 0;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--ink);
  background: rgba(242, 244, 247, 0.9);
  padding: 0 9px;
  outline: none;
}

.field-row input:focus {
  border-color: rgba(0, 122, 255, 0.45);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.toggle-stack {
  display: grid;
  gap: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.toggle-row input {
  width: 36px;
  height: 22px;
  accent-color: var(--blue);
}

.is-hidden {
  display: none;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(240px, 300px) minmax(330px, 1fr);
  }

  .control-panel {
    grid-column: 1 / -1;
    display: block;
  }

  .control-panel .panel-heading {
    margin-bottom: 18px;
  }

  .settings-sections {
    grid-template-columns: repeat(3, minmax(190px, 1fr));
    align-items: start;
    overflow: visible;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100% - 24px, 620px);
    margin: 12px auto;
  }

  .library-panel,
  .preview-stage,
  .control-panel {
    padding: 14px;
  }

  .control-panel {
    display: flex;
  }

  .settings-sections {
    grid-template-columns: 1fr;
  }

  .phone-wrap {
    min-height: 650px;
  }

  .phone-frame {
    width: min(330px, calc(100vw - 58px));
    height: min(680px, calc((100vw - 58px) * var(--phone-ratio)));
  }
}

@media (max-width: 460px) {
  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 19px;
  }

  .preview-topbar,
  .panel-heading {
    align-items: flex-start;
  }

  .preview-actions {
    flex-direction: column;
  }

  .phone-wrap {
    min-height: 580px;
  }

  .date-line {
    margin-top: 76px;
  }

  .widget-line {
    left: 34px;
    bottom: 126px;
  }

  .signature {
    right: 40px;
    bottom: 118px;
    font-size: 27px;
  }
}
