:root {
  color-scheme: light;
  --bg: #eff2f7;
  --surface: #ffffff;
  --border: #c7cfdb;
  --text: #1f2a3a;
  --muted: #5e6a7f;
  --accent: #0d5ea8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f6f8fb 0%, #e9eef6 100%);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, sans-serif;
  height: 100vh;
  overflow: hidden;
}

.about-page {
  min-height: 100vh;
  height: auto;
  overflow: auto;
  background:
    radial-gradient(circle at top right, rgba(13, 94, 168, 0.16), transparent 45%),
    linear-gradient(180deg, #f7f9fd 0%, #e7edf7 100%);
}

.about-shell {
  max-width: 860px;
  margin: 2.2rem auto;
  padding: 0 1rem 2rem;
}

.about-card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 28px rgba(23, 42, 70, 0.14);
  padding: 1.5rem 1.6rem;
  line-height: 1.6;
}

.about-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.9rem;
}

.about-header h1 {
  margin: 0;
  font-size: 1.35rem;
}

.about-signoff {
  margin-top: 1.1rem;
  font-weight: 600;
}

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: #dde5f2;
  padding: 0.8rem 1rem;
}

.toolbar h1 {
  margin: 0;
  font-size: 1.1rem;
}

.toolbar-actions {
  display: flex;
  gap: 0.6rem;
}

button {
  border: 1px solid #9aa8bf;
  background: linear-gradient(180deg, #f9fcff 0%, #dce6f4 100%);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
}

button:not(:disabled):hover {
  border-color: var(--accent);
}

.toolbar-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid #9aa8bf;
  background: linear-gradient(180deg, #f9fcff 0%, #dce6f4 100%);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.85rem;
}

.toolbar-link:hover {
  border-color: var(--accent);
}

.github-star-widget {
  display: inline-flex;
  align-items: stretch;
  align-self: center;
}

.github-star-button,
.github-star-count {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid #9aa8bf;
  background: linear-gradient(180deg, #f9fcff 0%, #dce6f4 100%);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1;
}

.github-star-button {
  gap: 0.4rem;
  border-radius: 4px 0 0 4px;
}

.github-star-count {
  justify-content: center;
  min-width: 3.2rem;
  border-left: 0;
  border-radius: 0 4px 4px 0;
  font-variant-numeric: tabular-nums;
}

.github-star-button:hover,
.github-star-count:hover {
  border-color: var(--accent);
}

.github-star-icon {
  color: #c28b00;
  font-size: 0.95rem;
}

.main-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.left-panel {
  border-right: 1px solid var(--border);
  background: #eef3fb;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.left-panel-main {
  flex: 0 0 auto;
}

.left-panel h2 {
  margin-top: 0;
  font-size: 1rem;
}

.sidebar-warning-panel {
  margin: 0.2rem 0 0.9rem;
  padding: 0.75rem 0.8rem;
  border: 1px solid #d1a862;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff7e8 0%, #f6e4bf 100%);
  color: #5b3810;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

.sidebar-warning-panel strong {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-warning-panel p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.serial-support-warning {
  margin: 0.35rem 0 0.8rem;
  padding: 0.55rem 0.6rem;
  border: 1px solid #d97b2f;
  border-radius: 6px;
  background: #fff4e8;
  color: #61330f;
  font-size: 0.82rem;
  line-height: 1.35;
}

.serial-support-warning a {
  color: #7b3f14;
  font-weight: 600;
}

.serial-support-warning[hidden] {
  display: none;
}

#radio-make,
#radio-model {
  width: 100%;
  margin: 0.2rem 0 0.55rem;
  padding: 0.4rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}

.left-panel button:disabled,
.left-panel input:disabled,
.left-panel select:disabled {
  color: #7d889a;
  border-color: #c4cbd8;
  background: linear-gradient(180deg, #eef2f8 0%, #dee5f0 100%);
  cursor: not-allowed;
}

.serial-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin: 0.3rem 0 0.6rem;
}

.serial-actions > :only-child {
  grid-column: 1 / -1;
}

.serial-log {
  margin: 0.6rem 0 0;
  min-height: 92px;
  max-height: 180px;
  overflow: auto;
  background: #f8fbff;
  border: 1px solid var(--border);
  padding: 0.45rem;
  font-size: 0.74rem;
  line-height: 1.4;
}

.editor-panel {
  padding: 1rem;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.editor-view-toggle {
  display: inline-flex;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.editor-view-toggle button {
  min-width: 8.5rem;
}

.editor-view-toggle button:disabled {
  color: #7d889a;
  border-color: #c4cbd8;
  background: linear-gradient(180deg, #eef2f8 0%, #dee5f0 100%);
  box-shadow: none;
  cursor: not-allowed;
}

.editor-view-toggle button.is-active {
  border-color: #20598d;
  background: linear-gradient(180deg, #fefefe 0%, #cfe3fb 100%);
  box-shadow: inset 0 0 0 1px rgba(32, 89, 141, 0.1);
}

.editor-view {
  min-height: 0;
  flex: 1 1 auto;
  display: none;
  flex-direction: column;
}

.editor-view.is-active {
  display: flex;
}

.channel-toolbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.6rem;
  flex: 0 0 auto;
  position: relative;
}

.mem-table-scroll {
  min-height: 0;
  overflow: auto;
  flex: 1 1 auto;
}

.settings-layout {
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 0.8rem;
}

.settings-tabs {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-right: 0.2rem;
}

.settings-tab {
  width: 100%;
  text-align: left;
}

.settings-tab.is-active {
  border-color: #20598d;
  background: linear-gradient(180deg, #fcfeff 0%, #d5e7fb 100%);
}

.settings-tab.has-invalid {
  border-color: #c44a4a;
  background: linear-gradient(180deg, #fff7f7 0%, #ffdede 100%);
}

.settings-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 22px rgba(20, 37, 61, 0.08);
}

.settings-summary {
  border-bottom: 1px solid var(--border);
  background: #eef5fe;
  color: #274466;
  padding: 0.7rem 0.9rem;
  font-size: 0.84rem;
}

.settings-summary.has-invalid {
  background: #fff0f0;
  color: #7d2424;
}

.settings-empty {
  margin: auto;
  max-width: 36rem;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}

.settings-content {
  min-height: 0;
  overflow: auto;
  padding: 0.9rem;
}

.settings-group {
  margin-bottom: 1rem;
  border: 1px solid #d6dfeb;
  border-radius: 8px;
  background: #f9fbff;
  overflow: hidden;
}

.settings-group > h3,
.settings-subgroup > h4 {
  margin: 0;
  padding: 0.65rem 0.8rem;
  background: #edf3fc;
  font-size: 0.88rem;
}

.settings-subgroup {
  border-top: 1px solid #d6dfeb;
}

.settings-fields {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 0.45rem 0.8rem;
  align-items: start;
  padding: 0.8rem;
}

.settings-field-label {
  font-size: 0.84rem;
  line-height: 1.35;
  color: #2f425a;
}

.settings-field-label strong {
  display: block;
  margin-bottom: 0.1rem;
  font-size: 0.86rem;
}

.settings-field-doc {
  color: var(--muted);
}

.settings-field-control {
  min-width: 0;
}

.settings-field-control input[type="text"],
.settings-field-control input[type="number"],
.settings-field-control select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  padding: 0.45rem 0.55rem;
}

.settings-field-control input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin-top: 0.4rem;
}

.settings-field-control.is-invalid input,
.settings-field-control.is-invalid select {
  border-color: #c44a4a;
  background: #fff1f1;
}

.settings-field-control.is-immutable input,
.settings-field-control.is-immutable select,
.settings-field-control.is-immutable label {
  color: #8390a2;
}

.settings-field-control.is-immutable input,
.settings-field-control.is-immutable select {
  background: #edf1f7;
}

.settings-field-error {
  margin-top: 0.25rem;
  color: #982b2b;
  font-size: 0.78rem;
  line-height: 1.3;
}

.settings-field-warning {
  margin-top: 0.25rem;
  color: #815112;
  font-size: 0.78rem;
  line-height: 1.3;
}

#channel-insert,
#channel-remove {
  min-width: 2.1rem;
  padding: 0.3rem 0.45rem;
  font-size: 1rem;
  line-height: 1;
}

.channel-menu {
  position: relative;
}

.channel-menu-popup {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  z-index: 20;
  min-width: 24rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: 0 6px 16px rgba(21, 37, 63, 0.16);
}

.channel-menu-popup.hidden {
  display: none;
}

.channel-menu-popup button {
  width: 100%;
  text-align: left;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 23, 40, 0.45);
  padding: 1rem;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  width: min(560px, 100%);
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(18, 35, 60, 0.3);
  padding: 1rem;
}

.modal-card h2 {
  margin: 0 0 0.8rem;
  font-size: 1rem;
}

.modal-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.45rem 0.7rem;
  align-items: center;
}

.modal-grid input[type="text"],
.modal-grid input[type="number"],
.modal-grid select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  padding: 0.35rem 0.45rem;
}

.modal-grid input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.modal-geo-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
  align-items: center;
}

.modal-geo-button {
  min-width: 2rem;
  padding: 0.35rem 0.45rem;
  line-height: 1;
}

.modal-modes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.35rem 0.55rem;
}

.modal-mode-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.modal-actions {
  margin-top: 0.9rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

#przemienniki-country {
  margin-bottom: 2em;
}

#przemienniki-band-list {
  margin-bottom: 2em;
}

#przemienniki-mode-list {
  margin-bottom: 2em;
}

.debug-output-panel {
  border-top: 1px solid var(--border);
  background: #e6edf8;
  padding: 0.7rem 0.9rem 0.9rem;
}

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.debug-actions {
  display: inline-flex;
  gap: 0.5rem;
}

.debug-header h2 {
  margin: 0;
  font-size: 0.9rem;
}

#report-issue {
  border-color: #965200;
  background: linear-gradient(180deg, #fff4df 0%, #f6d7ab 100%);
}

#debug-output {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--border);
  background: #f9fbff;
  color: var(--text);
  padding: 0.5rem;
  font-size: 0.78rem;
  line-height: 1.35;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

#mem-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  table-layout: fixed;
}

#mem-table th,
#mem-table td {
  border: 1px solid var(--border);
  padding: 0.35rem;
  font-size: 0.85rem;
}

#mem-table th {
  background: #e3ebf8;
  text-align: left;
}

#mem-table td input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
}

#mem-table td select {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
}

#mem-table .channel-location-button {
  width: 100%;
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}

#mem-table .channel-location-button:hover {
  color: #0b4b85;
  text-decoration: underline;
}

#mem-table .channel-location-button:focus-visible {
  outline: 1px solid var(--accent);
  background: #f2f8ff;
}

#mem-table tbody tr.is-selected td {
  background: #dcecff;
}

#mem-table td.is-invalid {
  background: #ffd9d9;
}

#mem-table td input:focus {
  outline: 1px solid var(--accent);
  background: #f2f8ff;
}

#mem-table td select:focus {
  outline: 1px solid var(--accent);
  background: #f2f8ff;
}

@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .left-panel {
    display: block;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

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

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

  .settings-tabs {
    flex-direction: row;
    overflow: auto;
    padding-right: 0;
    padding-bottom: 0.2rem;
  }

  .settings-tab {
    width: auto;
    white-space: nowrap;
  }

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