:root {
  color-scheme: dark;
  --bg: #080b14;
  --panel: rgba(19, 25, 42, .76);
  --panel-strong: #151b2c;
  --text: #f4f7ff;
  --muted: #939db3;
  --line: rgba(255, 255, 255, .09);
  --accent: #7c5cff;
  --accent-2: #2dd4bf;
  --danger: #ff5c77;
  --shadow: 0 22px 60px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: radial-gradient(circle at 40% -20%, #18213c 0, transparent 46%), var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { color: inherit; }

.ambient { position: fixed; width: 360px; height: 360px; border-radius: 50%; filter: blur(110px); opacity: .14; pointer-events: none; }
.ambient-one { background: #6d4aff; top: 5%; left: -180px; }
.ambient-two { background: #00d7bd; right: -210px; bottom: 5%; }
.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: max(48px, env(safe-area-inset-top)) 0 70px; position: relative; }
.topbar { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 42px; }
.eyebrow { color: var(--accent-2); font-weight: 800; font-size: .7rem; letter-spacing: .2em; margin: 0 0 10px; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -.055em; line-height: 1; margin: 0; }
.subtitle { color: var(--muted); font-size: 1rem; margin: 13px 0 0; }

button { border: 0; cursor: pointer; transition: transform .18s ease, filter .18s ease, background .18s ease; }
button:hover { filter: brightness(1.1); }
button:active { transform: scale(.97); }
.primary, .secondary, .danger { min-height: 46px; border-radius: 13px; padding: 0 18px; font-weight: 750; }
.primary { background: linear-gradient(135deg, #8467ff, #6243e7); box-shadow: 0 10px 28px rgba(100, 68, 230, .3); }
.secondary { background: #262d40; }
.danger { background: var(--danger); }

.category { margin-bottom: 38px; }
.category-title { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; color: #c9d0df; font-size: .8rem; letter-spacing: .13em; text-transform: uppercase; }
.category-title::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 16px; }
.tile {
  position: relative; min-height: 172px; padding: 21px; border: 1px solid var(--line); border-radius: 21px;
  background: linear-gradient(145deg, rgba(27, 35, 57, .88), rgba(14, 19, 33, .84));
  box-shadow: var(--shadow); backdrop-filter: blur(18px); cursor: grab; transition: transform .2s ease, border-color .2s ease;
}
.tile:hover { transform: translateY(-3px); border-color: rgba(124, 92, 255, .46); }
.tile.dragging { opacity: .4; }
.tile-top { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.app-icon { width: 53px; height: 53px; display: grid; place-items: center; border-radius: 16px; background: linear-gradient(145deg, rgba(124,92,255,.28), rgba(45,212,191,.14)); font-size: 1.55rem; font-weight: 800; }
.tile-menu { display: flex; gap: 4px; }
.icon-button { width: 36px; height: 36px; border-radius: 10px; background: transparent; color: #aeb7ca; font-size: 1.35rem; }
.icon-button:hover { background: rgba(255,255,255,.08); }
.tile-link { display: block; color: inherit; text-decoration: none; margin-top: 22px; }
.tile-name { margin: 0 0 7px; font-size: 1.1rem; font-weight: 760; }
.tile-url { color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.state { padding: 64px 20px; border: 1px dashed var(--line); border-radius: 20px; color: var(--muted); text-align: center; }

dialog { width: min(560px, calc(100% - 30px)); padding: 0; border: 1px solid var(--line); border-radius: 24px; color: var(--text); background: rgba(18, 23, 38, .97); box-shadow: 0 30px 100px #000; }
dialog::backdrop { background: rgba(2, 5, 12, .76); backdrop-filter: blur(7px); }
#app-form, .confirm-content { padding: 27px; }
.modal-heading { display: flex; justify-content: space-between; align-items: start; margin-bottom: 25px; }
.modal-heading h2, .confirm-content h2 { margin: 0; font-size: 1.5rem; }
.confirm-content p { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
label { display: grid; gap: 8px; color: #b8c0d1; font-size: .82rem; font-weight: 700; }
label.wide { grid-column: 1 / -1; }
input, select { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 0 13px; outline: 0; color: var(--text); background: #0d1220; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, .16); }
.toggle-row { display: flex; align-items: center; gap: 11px; cursor: pointer; margin-top: 3px; }
.toggle-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle { width: 42px; height: 24px; padding: 3px; border-radius: 20px; background: #30384c; transition: background .2s; }
.toggle::after { content: ""; display: block; width: 18px; height: 18px; border-radius: 50%; background: white; transition: transform .2s; }
.toggle-row input:checked + .toggle { background: var(--accent); }
.toggle-row input:checked + .toggle::after { transform: translateX(18px); }
#proxy-path-row.hidden { display: none; }
.form-error { min-height: 20px; margin: 13px 0 0; color: #ff8295; font-size: .85rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.confirm-dialog { max-width: 420px; }
#toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); padding: 12px 17px; border-radius: 12px; opacity: 0; pointer-events: none; color: white; background: #252d41; box-shadow: var(--shadow); transition: .25s; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 650px) {
  .shell { width: min(100% - 26px, 1180px); padding-top: 30px; }
  .topbar { align-items: stretch; flex-direction: column; margin-bottom: 30px; }
  .topbar .primary { width: 100%; }
  .tiles { grid-template-columns: 1fr; }
  .tile { min-height: 155px; }
  .form-grid { grid-template-columns: 1fr; }
  label.wide { grid-column: auto; }
  #app-form { padding: 21px; }
}

@media (min-width: 1200px) and (min-height: 700px) {
  .tile { min-height: 188px; }
  .tile-name { font-size: 1.2rem; }
}
