:root {
  --font: 'Sora', -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; font-family: var(--font); }
body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 20%, #2a1a4a 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, #0a3a5a 0%, transparent 50%),
    linear-gradient(160deg, #14162e, #0a0a12);
  color: #fff;
  overflow-x: hidden;
}

.desktop {
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 12px 40px;
  gap: 14px;
}

.title-badge {
  font-weight: 800; font-size: 22px; letter-spacing: -0.5px;
  display: flex; align-items: center; gap: 8px;
  text-shadow: 0 2px 20px rgba(120,80,255,0.5);
}
.vtag {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,0.12); padding: 2px 7px; border-radius: 6px;
}

/* Mode toggle segmented control */
.mode-toggle {
  display: flex; background: rgba(255,255,255,0.1); backdrop-filter: blur(20px);
  border-radius: 12px; padding: 3px; gap: 2px;
}
.seg {
  border: none; background: transparent; color: #cbd5e1;
  font-family: var(--font); font-weight: 600; font-size: 14px;
  padding: 7px 22px; border-radius: 9px; cursor: pointer;
  transition: all 0.25s;
}
.seg.active { background: #fff; color: #14162e; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }

/* Device frames */
.device {
  position: relative;
  background: linear-gradient(145deg, #3a3a3c, #1a1a1c);
  padding: 10px;
  transition: width 0.5s cubic-bezier(.2,.8,.2,1), height 0.5s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), inset 0 0 0 2px rgba(255,255,255,0.06);
}
.device.iphone {
  width: 330px; height: 680px; border-radius: 52px;
  max-width: 92vw;
}
.device.ipad {
  width: 640px; height: 720px; border-radius: 34px;
  max-width: 96vw;
}
.notch {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
  width: 110px; height: 30px; background: #000; border-radius: 20px; z-index: 20;
}

.screen {
  position: relative; width: 100%; height: 100%;
  border-radius: 44px; overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, #ffd6e8 0%, transparent 45%),
    radial-gradient(circle at 70% 75%, #c2e9fb 0%, transparent 45%),
    linear-gradient(160deg, #fbc2eb, #a6c1ee);
  display: flex; flex-direction: column;
}
.device.ipad .screen { border-radius: 26px; }
.screen.dark {
  background:
    radial-gradient(circle at 30% 15%, #4a2a7a 0%, transparent 50%),
    radial-gradient(circle at 75% 80%, #1a3a6a 0%, transparent 50%),
    linear-gradient(160deg, #1a1a3e, #0a0a1a);
}

/* Status bar */
.statusbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 26px 4px; font-size: 13px; font-weight: 700; color: #111;
  flex-shrink: 0;
}
.statusbar.dark { color: #fff; }
.device.iphone .statusbar { padding-top: 16px; }
.sb-time { font-variant-numeric: tabular-nums; }
.sb-right { display: flex; align-items: center; gap: 4px; font-size: 11px; }
.battery {
  display: inline-block; width: 22px; height: 11px; border: 1.5px solid currentColor;
  border-radius: 3px; margin-left: 4px; position: relative; padding: 1px;
}
.battery::after { content: ""; position: absolute; right: -3px; top: 3px; width: 2px; height: 5px; background: currentColor; border-radius: 1px; }
.battery-fill { display: block; width: 80%; height: 100%; background: currentColor; border-radius: 1px; }

/* Home screen */
.home { flex: 1; padding: 18px 20px 0; overflow-y: auto; }
.grid { display: grid; gap: 20px 8px; }

.app-icon-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; position: relative;
  transition: transform 0.12s;
}
.app-icon-wrap:active { transform: scale(0.88); }
.app-icon {
  width: 58px; height: 58px; border-radius: 15px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 14px rgba(0,0,0,0.25);
}
.app-icon-img { width: 58px; height: 58px; border-radius: 15px; object-fit: cover; box-shadow: 0 6px 14px rgba(0,0,0,0.25); }
.device.ipad .app-icon, .device.ipad .app-icon-img { width: 64px; height: 64px; border-radius: 16px; }
.glyph { font-size: 30px; line-height: 1; }
.app-icon .glyph { filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3)); }
.app-label {
  font-size: 11px; font-weight: 500; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6); text-align: center;
  max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@keyframes jiggle {
  0% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } 100% { transform: rotate(-2deg); }
}
.jiggle .app-icon, .jiggle .app-icon-img { animation: jiggle 0.28s infinite; }
.delete-badge {
  position: absolute; top: -6px; left: 4px; z-index: 5;
  width: 22px; height: 22px; border-radius: 50%; border: none;
  background: #ddd; color: #333; font-size: 16px; font-weight: 700;
  line-height: 1; cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.jiggle-hint {
  text-align: center; margin-top: 20px; font-size: 12px; color: rgba(255,255,255,0.7);
}

/* Dock */
.dock {
  margin: 8px 14px 26px; padding: 12px 10px;
  background: rgba(255,255,255,0.28); backdrop-filter: blur(20px);
  border-radius: 26px; display: flex; justify-content: space-around;
  flex-shrink: 0; border: 1px solid rgba(255,255,255,0.3);
}
.dock.dark { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.15); }
.dock .app-label { display: none; }
.dock .app-icon-wrap { gap: 0; }

/* Home indicator */
.home-indicator {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  width: 130px; height: 5px; border-radius: 3px; background: rgba(0,0,0,0.35);
  cursor: pointer; z-index: 15;
}
.screen.dark .home-indicator { background: rgba(255,255,255,0.5); }

/* App view */
.app-view {
  position: absolute; inset: 0; top: 0; z-index: 10;
  background: #f2f2f7; display: flex; flex-direction: column;
  animation: zoomIn 0.32s cubic-bezier(.2,.8,.2,1);
  padding-top: 40px;
}
.app-view.dark { background: #000; }
@keyframes zoomIn { from { transform: scale(0.6); opacity: 0.2; } to { transform: scale(1); opacity: 1; } }
.app-view-body { flex: 1; overflow-y: auto; padding-bottom: 24px; }

/* Calculator */
.calc { padding: 12px; display: flex; flex-direction: column; height: 100%; }
.calc-disp {
  color: #fff; text-align: right; font-size: 58px; font-weight: 200;
  padding: 20px 16px; font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis;
}
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 8px; }
.calc-btn {
  border: none; border-radius: 50%; aspect-ratio: 1; font-size: 26px;
  font-family: var(--font); font-weight: 400; cursor: pointer;
  color: #fff; transition: filter 0.1s;
}
.calc-btn:active { filter: brightness(1.4); }
.calc-btn.dark { background: #333; }
.calc-btn.gray { background: #a5a5a5; color: #000; }
.calc-btn.orange { background: #ff9f0a; }
.calc-btn.zero { grid-column: span 2; aspect-ratio: unset; border-radius: 40px; text-align: left; padding-left: 26px; }

/* Weather */
.weather { padding: 16px; color: #fff; }
.weather-search { display: flex; gap: 8px; margin-bottom: 16px; }
.w-input { flex: 1; padding: 10px 14px; border-radius: 12px; border: none; background: rgba(255,255,255,0.15); color: #fff; font-family: var(--font); font-size: 14px; }
.w-input::placeholder { color: rgba(255,255,255,0.5); }
.w-go { padding: 10px 16px; border: none; border-radius: 12px; background: #0a84ff; color: #fff; font-weight: 600; cursor: pointer; }
.w-msg { text-align: center; padding: 20px; color: rgba(255,255,255,0.8); }
.w-msg.err { color: #ff6b6b; }
.w-card { text-align: center; padding: 20px; }
.w-loc { font-size: 22px; font-weight: 600; }
.w-emoji { font-size: 70px; margin: 10px 0; }
.w-temp { font-size: 60px; font-weight: 200; }
.w-wind { color: rgba(255,255,255,0.7); margin-top: 8px; }
.w-range { margin-top: 12px; font-weight: 600; font-family: var(--mono); }

/* Notes */
.notes { display: flex; flex-direction: column; height: 100%; padding: 16px; }
.notes-head { font-size: 26px; font-weight: 800; margin-bottom: 12px; color: #1c1c1e; }
.app-view.dark .notes-head { color: #fff; }
.notes-area {
  flex: 1; min-height: 300px; border: none; resize: none; font-size: 16px;
  font-family: var(--font); background: transparent; color: #1c1c1e; outline: none; line-height: 1.5;
}
.app-view.dark .notes-area { color: #f0f0f0; }

/* Dice */
.dice { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 20px; padding: 20px; }
.dice-face { font-size: 130px; line-height: 1; color: #fff; }
.app-view:not(.dark) .dice-face { color: #1c1c1e; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.dice-face.spin { animation: spin 0.3s linear infinite; }
.dice-btn, .coin-btn {
  padding: 12px 28px; border: none; border-radius: 14px; background: #43e97b;
  color: #003; font-weight: 700; font-size: 16px; cursor: pointer;
}
.coin-row { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 20px; }
.coin-res { font-size: 24px; font-weight: 600; color: #fff; }
.app-view:not(.dark) .coin-res { color: #1c1c1e; }
.coin-btn { background: #f6d365; }

/* Terminal */
.terminal { background: #000; color: #33ff66; font-family: var(--mono); font-size: 13px; padding: 20px; min-height: 100%; line-height: 1.7; }
.term-line { white-space: pre-wrap; word-break: break-word; }

/* Photos */
.photos { padding: 16px; color: #fff; display: flex; flex-direction: column; gap: 12px; height: 100%; }
.photos-head { font-size: 24px; font-weight: 800; }
.photos-in { display: flex; gap: 8px; }
.photos-img { width: 100%; border-radius: 16px; }
.photos-empty { color: rgba(255,255,255,0.6); text-align: center; padding: 40px 10px; }

/* Store */
.store { padding: 20px; color: #1c1c1e; display: flex; flex-direction: column; gap: 8px; }
.app-view.dark .store { color: #fff; }
.store-head { font-size: 28px; font-weight: 800; }
.store-sub { font-size: 13px; opacity: 0.7; margin-bottom: 10px; }
.store-lbl { font-size: 12px; font-weight: 600; opacity: 0.6; margin-top: 8px; }
.store-input { padding: 11px 14px; border-radius: 12px; border: 1px solid rgba(120,120,120,0.3); background: rgba(120,120,120,0.1); color: inherit; font-family: var(--font); font-size: 15px; }
.grad-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 4px; }
.grad-swatch { aspect-ratio: 1; border-radius: 10px; border: 2px solid transparent; cursor: pointer; }
.grad-swatch.sel { border-color: #0a84ff; transform: scale(1.1); }
.store-get { margin-top: 16px; padding: 13px; border: none; border-radius: 16px; background: #0a84ff; color: #fff; font-weight: 800; font-size: 16px; letter-spacing: 1px; cursor: pointer; }

/* Settings */
.settings-app { padding: 16px; color: #1c1c1e; }
.settings-app.dark { color: #fff; }
.settings-title { font-size: 28px; font-weight: 800; margin-bottom: 16px; }
.set-group { background: rgba(120,120,120,0.12); border-radius: 14px; margin-bottom: 20px; overflow: hidden; }
.set-cell { display: flex; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid rgba(120,120,120,0.15); cursor: pointer; font-size: 15px; }
.set-cell:last-child { border-bottom: none; }
.set-right { opacity: 0.5; }
.set-note { font-size: 12px; opacity: 0.55; line-height: 1.5; padding: 0 4px; }

/* Blank app */
.blank-app { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 30px; text-align: center; color: #1c1c1e; }
.app-view.dark .blank-app { color: #fff; }
.blank-glyph { font-size: 80px; }
.blank-title { font-size: 24px; font-weight: 800; margin: 12px 0; }
.blank-msg { font-size: 14px; opacity: 0.65; line-height: 1.6; max-width: 320px; }

/* Done button */
.done-btn {
  padding: 8px 24px; border: none; border-radius: 20px; background: #fff; color: #14162e;
  font-weight: 700; cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: #1c1c2e; border-radius: 22px; padding: 24px; width: 100%; max-width: 340px; text-align: center; border: 1px solid rgba(255,255,255,0.1); }
.modal-title { font-size: 20px; font-weight: 800; margin-bottom: 16px; }
.modal-drop { border: 2px dashed rgba(255,255,255,0.3); border-radius: 16px; padding: 30px 20px; font-size: 40px; display: flex; flex-direction: column; gap: 8px; align-items: center; margin-bottom: 18px; }
.modal-drop div { font-size: 15px; }
.modal-drop small { font-size: 12px; opacity: 0.5; }
.modal-btn { width: 100%; padding: 13px; border: none; border-radius: 14px; background: #0a84ff; color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; }
.modal-cancel { width: 100%; padding: 12px; border: none; background: transparent; color: rgba(255,255,255,0.6); font-family: var(--font); cursor: pointer; margin-top: 8px; }
.spinner-txt { margin-bottom: 16px; opacity: 0.8; }
.progbar { height: 10px; background: rgba(255,255,255,0.15); border-radius: 5px; overflow: hidden; }
.progfill { height: 100%; background: linear-gradient(90deg, #0a84ff, #5ee7df); transition: width 0.18s; }
.done-msg { opacity: 0.7; margin-bottom: 18px; }

/* Toast */
.toast {
  position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%);
  background: rgba(20,20,30,0.95); color: #fff; padding: 12px 22px; border-radius: 30px;
  font-size: 14px; font-weight: 600; z-index: 200; box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.15); animation: toastUp 0.3s;
}
@keyframes toastUp { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* Footer */
.footer { font-size: 12px; color: rgba(255,255,255,0.4); text-align: center; margin-top: 6px; }
.footer a { color: #5ee7df; text-decoration: none; font-weight: 600; }
.footer a:hover { text-decoration: underline; }