:root {
  color-scheme: light;
  --bg-color: #edf3ee;
  --bg-accent: rgba(123, 158, 133, 0.18);
  --panel-color: #e8efea;
  --surface-color: #f4f7f5;
  --surface-strong: #d8e3dc;
  --surface-border: #d7e2db;
  --shadow-elevated: rgba(138, 157, 145, 0.3);
  --shadow-light: rgba(255, 255, 255, 0.94);
  --shadow-dark: rgba(185, 199, 190, 0.88);
  --text-color: #1f3027;
  --text-muted: #698272;
  --brand-green: #7ca989;
  --brand-green-dark: #6f9c7e;
  --accent-color: #7458b5;
  --danger-color: #da94a0;
  --success-color: #5fb174;
  --warning-color: #b88b2d;
  --shell-width: 222px;
  --shell-height: 550px;
  --page-padding: 12px;
  --shell-radius: 20px;
  --font-body: "Montserrat", "Yu Gothic UI", "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-color: #0c110e;
  --bg-accent: rgba(132, 181, 150, 0.14);
  --panel-color: #18201c;
  --surface-color: #222d27;
  --surface-strong: #223029;
  --surface-border: #314038;
  --shadow-elevated: rgba(0, 0, 0, 0.52);
  --shadow-light: rgba(255, 255, 255, 0.05);
  --shadow-dark: rgba(0, 0, 0, 0.42);
  --text-color: #f3fbf6;
  --text-muted: #adc4b7;
  --brand-green: #8eb89a;
  --brand-green-dark: #7ba787;
  --accent-color: #d2bcff;
  --danger-color: #ff9ead;
  --success-color: #7de0a8;
  --warning-color: #f1d188;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text-color);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, var(--bg-accent), transparent 38%),
    linear-gradient(180deg, var(--bg-color) 0%, var(--bg-color) 100%);
}

button,
input {
  font: inherit;
}

button {
  appearance: none;
  border: 0;
  cursor: pointer;
  background: transparent;
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

input {
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  background: var(--surface-color);
  color: var(--text-color);
  font-size: 11px;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.95),
    -2px -2px 6px rgba(255, 255, 255, 0.8),
    3px 3px 8px rgba(197, 208, 201, 0.75);
}

:root[data-theme="dark"] input {
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.04),
    -2px -2px 6px rgba(255, 255, 255, 0.02),
    3px 3px 8px rgba(0, 0, 0, 0.32);
}

input::placeholder {
  color: var(--text-muted);
}

code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92em;
}

.hidden {
  display: none !important;
}

.page-shell {
  padding: var(--page-padding);
}

.launcher-page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.settings-page {
  display: block;
}

.window-surface.page-shell {
  padding: 0;
}

.app-shell {
  width: min(100%, var(--shell-width));
  min-height: min(calc(100vh - (var(--page-padding) * 2)), var(--shell-height));
  max-height: min(calc(100vh - (var(--page-padding) * 2)), var(--shell-height));
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 9px 8px;
  overflow: hidden;
  border-radius: var(--shell-radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 18%),
    linear-gradient(180deg, rgba(12, 18, 14, 0.9), rgba(12, 18, 14, 0.96));
  border: 1px solid rgba(213, 235, 221, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 22px 50px var(--shadow-elevated);
}

:root[data-theme="light"] .app-shell {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(228, 236, 231, 0.96));
  border-color: rgba(126, 154, 136, 0.18);
}

.settings-shell {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 20px;
  border-radius: 28px;
  background: var(--bg-color);
}

.window-surface.launcher-page {
  display: block;
}

.window-surface .app-shell {
  width: 100%;
  height: 100vh;
  min-height: 100vh;
  max-height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.window-surface .settings-shell {
  width: 100%;
  min-height: 100vh;
  padding: 20px;
  border-radius: 0;
  background: transparent;
}

.header,
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.header {
  padding: 2px 1px 0;
}

.settings-header {
  margin-bottom: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-badge {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(226, 236, 229, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    0 10px 18px rgba(127, 149, 136, 0.18);
  overflow: hidden;
  flex: none;
}

:root[data-theme="dark"] .brand-badge {
  background: linear-gradient(180deg, #27342d, #1b241f);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 12px 22px rgba(0, 0, 0, 0.32);
}

.settings-header .brand-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.brand-badge img {
  width: 18px;
  height: 18px;
  object-fit: cover;
}

.brand-copy {
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-header .brand-title {
  font-size: 18px;
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 6px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn,
.neo-btn,
.banner-btn,
.brand-btn,
.launcher-btn,
.tab-btn {
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

.icon-btn,
.neo-btn,
.banner-btn,
.tab-btn {
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  background: linear-gradient(180deg, #f9fbfa, #e9f0eb);
  box-shadow:
    -3px -3px 8px rgba(255, 255, 255, 0.86),
    4px 4px 10px rgba(191, 203, 196, 0.8);
}

:root[data-theme="dark"] .icon-btn,
:root[data-theme="dark"] .neo-btn,
:root[data-theme="dark"] .banner-btn,
:root[data-theme="dark"] .tab-btn {
  background: linear-gradient(180deg, #29352f, #202924);
  box-shadow:
    -3px -3px 8px rgba(255, 255, 255, 0.03),
    4px 4px 10px rgba(0, 0, 0, 0.34);
}

.icon-btn:hover,
.neo-btn:hover,
.banner-btn:hover,
.launcher-btn:hover,
.tab-btn:hover,
.brand-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.icon-btn:active,
.neo-btn:active,
.banner-btn:active,
.launcher-btn:active,
.tab-btn:active,
.brand-btn:active {
  transform: translateY(1px) scale(0.99);
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--accent-color);
  font-size: 18px;
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.24);
  border: 1px solid rgba(126, 154, 136, 0.2);
}

:root[data-theme="dark"] .banner {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

.banner strong {
  display: block;
  font-size: 12px;
}

.banner p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.banner-btn {
  min-height: 38px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tabs-wrap {
  padding: 0 1px 0;
}

.tabs {
  display: flex;
  gap: 6px;
}

.launcher-tabs .tab-btn,
.tabs-editor .tab-btn {
  flex: 1;
}

.tabs-editor {
  margin-bottom: 14px;
}

.tab-btn {
  min-width: 0;
  min-height: 32px;
  padding: 6px 7px;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  color: var(--text-muted);
}

.tab-label {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tab-btn.active,
.theme-btn.active {
  color: var(--brand-green-dark);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 0 0 1px rgba(124, 169, 137, 0.18),
    -3px -3px 8px rgba(255, 255, 255, 0.9),
    5px 5px 12px rgba(180, 195, 187, 0.85);
}

:root[data-theme="dark"] .tab-btn.active,
:root[data-theme="dark"] .theme-btn.active {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 0 0 1px rgba(142, 184, 154, 0.18),
    -3px -3px 8px rgba(255, 255, 255, 0.03),
    5px 5px 12px rgba(0, 0, 0, 0.36);
}

.content {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 0 2px;
}

.button-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 1px 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(95, 139, 114, 0.34) rgba(126, 154, 136, 0.12);
}

.button-container::-webkit-scrollbar {
  width: 8px;
}

.button-container::-webkit-scrollbar-track {
  background: rgba(126, 154, 136, 0.12);
  border-radius: 999px;
}

.button-container::-webkit-scrollbar-thumb {
  background: rgba(95, 139, 114, 0.34);
  border-radius: 999px;
}

.launcher-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(146px, calc(100% - 34px));
  min-height: 34px;
  margin: 0 auto 6px;
  padding: 6px 10px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), var(--surface-color) 58%, var(--surface-strong) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.98),
    inset 0 -1px 0 rgba(116, 144, 127, 0.08),
    0 11px 20px rgba(129, 150, 139, 0.18),
    0 2px 4px rgba(107, 126, 115, 0.08);
  border: 1px solid rgba(126, 154, 136, 0.18);
  color: var(--text-color);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.launcher-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 60%);
  opacity: 0.8;
  pointer-events: none;
}

:root[data-theme="dark"] .launcher-btn {
  background: linear-gradient(180deg, #243029 0%, #1d2823 58%, #18201c 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(255, 255, 255, 0.03),
    0 14px 24px rgba(0, 0, 0, 0.34),
    0 2px 5px rgba(0, 0, 0, 0.2);
  border-color: rgba(213, 235, 221, 0.1);
}

:root[data-theme="dark"] .launcher-btn::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 58%);
}

.launcher-btn-label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.empty-state {
  padding: 36px 18px;
  border-radius: 18px;
  text-align: center;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.34);
  border: 1px dashed rgba(126, 154, 136, 0.2);
}

:root[data-theme="dark"] .empty-state {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

.footer {
  flex: none;
  margin-top: auto;
  padding-bottom: 2px;
}

.footer-copy {
  margin: 0;
  text-align: center;
  font-size: 7px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-desc,
.settings-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.65;
}

.settings-desc {
  margin: 0 0 18px;
}

.neo-box {
  margin-bottom: 18px;
  padding: 16px 14px;
  border-radius: 18px;
  background: var(--panel-color);
  box-shadow:
    -6px -6px 14px var(--shadow-light),
    8px 8px 18px var(--shadow-dark);
}

.neo-box h2 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
}

.settings-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.window-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.protocol-field {
  margin-top: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.input-group span,
.list-header {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.theme-switcher {
  display: flex;
  gap: 10px;
}

.theme-btn {
  flex: 1;
}

.neo-btn {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
}

.list-header,
.row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 56px 50px;
  gap: 10px;
  align-items: center;
}

.list-header {
  margin-bottom: 8px;
  padding: 0 2px;
}

.data-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.move-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-btn {
  min-height: 16px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mini-btn::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

.btn-move-up::before {
  border-bottom: 6px solid currentColor;
}

.btn-move-down::before {
  border-top: 6px solid currentColor;
}

.mini-btn:disabled {
  cursor: default;
  opacity: 0.45;
  transform: none;
  filter: none;
}

.btn-delete {
  color: var(--danger-color);
  min-height: 38px;
}

.add-row-btn {
  margin-top: 14px;
}

.actions-card {
  margin-bottom: 0;
}

.utility-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 24px;
}

.brand-btn {
  min-width: 144px;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--brand-green), var(--brand-green-dark));
  color: #f9fffb;
  font-size: 13px;
  font-weight: 700;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 10px 18px rgba(130, 162, 141, 0.34);
}

:root[data-theme="dark"] .brand-btn {
  background: linear-gradient(180deg, #3d6450, #2d4a3a);
  color: #f2fbf5;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 10px 18px rgba(0, 0, 0, 0.32);
}

.settings-footer {
  margin-top: 24px;
  padding: 0 0 4px;
  text-align: center;
  color: var(--text-muted);
  font-size: 8px;
  line-height: 1.7;
}

.window-surface .settings-footer {
  padding-bottom: 16px;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 30;
}

.toast {
  min-width: 240px;
  max-width: min(92vw, 360px);
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid var(--surface-border);
  background: rgba(13, 20, 16, 0.96);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.24);
  color: var(--text-color);
  font-size: 12px;
  line-height: 1.6;
}

:root[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.96);
}

.toast[data-tone="success"] {
  border-color: rgba(95, 177, 116, 0.32);
}

.toast[data-tone="warning"] {
  border-color: rgba(184, 139, 45, 0.32);
}

.toast[data-tone="error"] {
  border-color: rgba(218, 148, 160, 0.32);
}

@media (max-width: 540px) {
  .page-shell {
    padding: 0;
  }

  .settings-shell {
    width: 100%;
    min-height: 100vh;
    border-radius: 0;
    padding: 20px 16px;
  }

  .form-grid,
  .utility-actions {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }

  .brand-btn {
    min-width: 0;
  }

  .list-header {
    display: none;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .move-controls {
    flex-direction: row;
  }

  .banner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 420px) {
  .settings-page .theme-switcher,
  .settings-page .tabs {
    flex-direction: column;
  }

  .window-fields {
    grid-template-columns: 1fr;
  }
}
