:root {
  --bg: #04141e;
  --panel: #0b2230;
  --panel-2: #0d2938;
  --line: #28495d;
  --text: #f4f8fb;
  --muted: #aebfca;
  --accent: #55c6f2;
  --accent-2: #2e9ed0;
  --danger: #ff9a9a;
  --success: #7ad99a;
  --warning: #ffd27a;
  --shadow: 0 12px 36px rgba(0,0,0,.24);
  --keyboard-offset: 0px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); min-height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  min-width: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 85% -10%, rgba(85,198,242,.12), transparent 34rem),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font-family: inherit; }
button { -webkit-touch-callout: none; }

.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  gap: 28px;
  padding: env(safe-area-inset-top) 24px env(safe-area-inset-bottom);
  background: var(--bg);
  transition: opacity .25s ease, visibility .25s ease;
}
.splash.hidden-splash { opacity: 0; visibility: hidden; }
.splash-logo {
  font: 900 clamp(24px, 7vw, 38px)/1.15 Arial, Helvetica, sans-serif;
  letter-spacing: .02em;
  text-align: center;
}
.splash-logo strong { color: var(--accent); }
.splash-spinner {
  justify-self: center;
  width: 34px;
  height: 34px;
  border: 3px solid rgba(85,198,242,.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(16px + env(safe-area-inset-top)) 20px 15px;
  background: rgba(4,20,30,.96);
  border-bottom: 1px solid rgba(85,198,242,.2);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.header-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.brand {
  min-width: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(19px, 5.6vw, 30px);
  line-height: 1.12;
  letter-spacing: .02em;
  white-space: nowrap;
}
.brand strong { color: var(--accent); font-weight: 900; }
.current-template {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.network-badge {
  flex: 0 0 auto;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  color: var(--muted);
  background: rgba(13,41,56,.75);
  font-size: 11px;
}
.network-badge.online { color: var(--success); border-color: rgba(122,217,154,.45); }
.network-badge.offline { color: var(--warning); border-color: rgba(255,210,122,.45); }

.page { width: min(760px, 100%); margin: 0 auto; padding: 18px 16px 0; min-width: 0; }
.card, .notice-card {
  background: linear-gradient(145deg, rgba(13,41,56,.98), rgba(8,31,43,.98));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  margin: 0 0 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.selector-card { border-color: rgba(85,198,242,.34); }
.notice-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  border-color: rgba(85,198,242,.38);
  font-size: 13px;
  line-height: 1.45;
}
.notice-card b { color: var(--accent); font-size: 14px; }
.notice-card span { color: var(--muted); }
.notice-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.progress { height: 8px; overflow: hidden; border-radius: 999px; background: #071b26; border: 1px solid #294b5f; }
.progress i { display: block; width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .18s ease; }
.text-button {
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 6px 0 0;
  font-size: 14px;
  font-weight: 600;
}

h1, h2 { margin: 0; }
h1 { font-size: 19px; line-height: 1.3; margin-bottom: 18px; }
h2 {
  color: var(--accent);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .09em;
  margin-bottom: 17px;
}
.grid { display: grid; gap: 15px; min-width: 0; }
.grid.two { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; min-width: 0; }
.field > span { color: #d7e3ea; font-size: 15px; margin: 0 0 8px; }
.field em { color: var(--accent); font-style: normal; }
.field small, .switch-row small, .result-actions small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 8px;
}
input, select, textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 1px solid #31566b;
  border-radius: 18px;
  background: #071b26;
  color: var(--text);
  font: 400 17px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  outline: none;
  padding: 15px 17px;
  min-height: 56px;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
  -webkit-appearance: none;
  appearance: none;
}
select {
  padding-right: 44px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 21px) calc(50% - 2px),
    calc(100% - 15px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
textarea { resize: vertical; min-height: 150px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(85,198,242,.13);
  background-color: #08202c;
}
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger); }
input:disabled, select:disabled, textarea:disabled { opacity: .62; }

.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 2px;
  cursor: pointer;
}
.switch-row b { display: block; font-size: 15px; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 1px; }
.switch-row i {
  flex: 0 0 54px;
  height: 31px;
  border-radius: 999px;
  background: #294657;
  border: 1px solid #406175;
  position: relative;
  transition: .2s ease;
}
.switch-row i::after {
  content: '';
  position: absolute;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  left: 3px;
  top: 3px;
  background: #dbe7ed;
  transition: .2s ease;
}
.switch-row input:checked + i { background: var(--accent-2); border-color: var(--accent); }
.switch-row input:checked + i::after { transform: translateX(23px); background: white; }
.conditional { padding-top: 5px; }

.button {
  width: 100%;
  border: 0;
  border-radius: 19px;
  min-height: 62px;
  padding: 15px 18px;
  font: 800 19px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}
.button:disabled { opacity: .55; cursor: wait; }
.button.primary {
  color: #06202d;
  background: linear-gradient(135deg, #5bd0fa, #49b9ed);
  box-shadow: 0 12px 30px rgba(57,173,222,.25);
}
.button.secondary {
  color: white;
  background: #254b60;
  border: 1px solid #3f687e;
}
.button.ghost {
  color: var(--muted);
  background: transparent;
  border: 1px solid #31566b;
  min-height: 54px;
  font-size: 16px;
}
.button.danger { color: var(--danger); border-color: rgba(255,154,154,.35); }
.button:active { transform: translateY(1px); }
.result-actions { text-align: center; }
.data-actions { padding: 14px; }

.status-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 15px 17px;
  margin: 0 0 16px;
  background: rgba(11,34,48,.96);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.status-card.success { border-color: rgba(122,217,154,.5); color: var(--success); }
.status-card.error { border-color: rgba(255,154,154,.5); color: var(--danger); }

.create-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--keyboard-offset);
  z-index: 25;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(4,20,30,.72));
  transition: bottom .12s ease;
}
.create-bar .button { display: block; width: min(728px, calc(100vw - 32px)); margin: 0 auto; }
.bottom-space { height: calc(96px + env(safe-area-inset-bottom)); }
body.keyboard-open .create-bar { position: static; padding: 8px 0 0; background: transparent; }
body.keyboard-open .bottom-space { height: 0; }
.hidden { display: none !important; }

noscript { display: block; padding: 30px; color: white; background: #600; }

@media (min-width: 620px) {
  .page { padding-left: 22px; padding-right: 22px; }
  .grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .field.wide { grid-column: 1 / -1; }
  .card, .notice-card { padding: 24px; }
}

@media (max-width: 370px) {
  .app-header { padding-left: 14px; padding-right: 14px; }
  .page { padding-left: 12px; padding-right: 12px; }
  .card, .notice-card { padding: 17px; border-radius: 21px; }
  .brand { font-size: 18px; }
  .network-badge { max-width: 86px; font-size: 10px; }
  input, select, textarea { font-size: 16px; padding-left: 14px; padding-right: 14px; }
}

@media (display-mode: standalone) {
  .app-header { padding-top: calc(13px + env(safe-area-inset-top)); }
}
