:root {
  color: #13212d;
  background: #dbe8f2;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 28px;
  border: 1px solid #6d7d89;
  border-radius: 3px;
  color: #17232d;
  background: rgba(242, 247, 250, 0.94);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.96), 0 1px 2px rgba(22, 39, 52, 0.22);
  cursor: pointer;
}

button:hover {
  border-color: #3e7fba;
  background: rgba(230, 244, 253, 0.98);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid #f0bd35;
  outline-offset: 2px;
}

.app-window {
  display: grid;
  grid-template-rows: 34px 30px 39px minmax(0, 1fr) 25px;
  width: 100%;
  height: 100%;
  border: 1px solid #6f8799;
  background: #eef4f8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}

.app-window.desktop {
  grid-template-rows: 30px 39px minmax(0, 1fr) 25px;
}

.app-window.desktop .titlebar {
  display: none;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 9px;
  border-bottom: 1px solid #7894a8;
  color: #102434;
  background: rgba(190, 220, 240, 0.94);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.9);
  user-select: none;
}

.titlebar img {
  width: 21px;
  height: 21px;
}

.titlebar-title {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-switch {
  display: inline-flex;
  gap: 2px;
  margin-left: auto;
}

.language-switch button {
  min-width: 38px;
  min-height: 23px;
  padding: 0 7px;
  font-size: 12px;
}

.language-switch button[aria-pressed="true"] {
  border-color: #28689e;
  color: #fff;
  background: #337fb7;
}

.menubar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: stretch;
  padding: 1px 6px 0;
  border-bottom: 1px solid #a3b2bd;
  background: rgba(249, 251, 252, 0.97);
}

.menu {
  position: relative;
}

.menu-trigger {
  min-height: 26px;
  padding: 0 10px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.menu-trigger[aria-expanded="true"] {
  border-color: #8aa4b8;
  background: #e5f0f8;
}

.menu-popup {
  position: absolute;
  top: calc(100% - 1px);
  left: 0;
  min-width: 230px;
  margin: 0;
  padding: 4px;
  border: 1px solid #758b9b;
  background: rgba(250, 252, 253, 0.99);
  box-shadow: 3px 4px 11px rgba(12, 29, 41, 0.3);
}

.menu-popup[hidden] {
  display: none;
}

.menu-popup button,
.menu-popup a {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 29px;
  padding: 4px 20px 4px 9px;
  border: 0;
  border-radius: 2px;
  color: #17232d;
  background: transparent;
  box-shadow: none;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}

.menu-popup button:hover,
.menu-popup a:hover {
  background: #dcecf7;
}

.recent-location-menu {
  display: grid;
  gap: 3px;
  min-width: 255px;
  padding: 7px 12px 9px;
  color: #20384a;
  font-size: 12px;
}

.recent-location-menu select {
  width: 100%;
  min-height: 27px;
  border: 1px solid #8496a3;
  background: #fff;
}

.menu-separator {
  height: 1px;
  margin: 4px 3px;
  background: #c5d1da;
}

.tabbar {
  display: flex;
  align-items: end;
  gap: 2px;
  padding: 5px 8px 0;
  border-bottom: 1px solid #8197a8;
  background: #d8e5ee;
}

.tabbar button {
  min-height: 33px;
  padding: 0 18px;
  border-radius: 4px 4px 0 0;
  border-bottom-color: #8197a8;
  background: rgba(220, 233, 242, 0.96);
}

.tabbar button[aria-selected="true"] {
  position: relative;
  top: 1px;
  border-color: #8197a8;
  border-bottom-color: #f6f9fb;
  color: #0b395b;
  background: #f6f9fb;
  font-weight: 600;
}

main,
main section,
iframe {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
}

main section[hidden] {
  display: none;
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 8px;
  border-top: 1px solid #9bacb8;
  color: #213744;
  background: #e8f0f5;
  font-size: 12px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border: 1px solid #296a45;
  border-radius: 50%;
  background: #55a878;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.75);
}

.status-model {
  overflow: hidden;
  margin-left: auto;
  color: #526570;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 18px;
  top: 112px;
  max-width: min(520px, calc(100vw - 36px));
  padding: 10px 13px;
  border: 1px solid #54768b;
  border-radius: 4px;
  color: #102532;
  background: rgba(235, 247, 253, 0.98);
  box-shadow: 2px 3px 10px rgba(18, 34, 45, 0.3);
}

.toast[hidden] {
  display: none;
}

.toast.dialog-toast {
  position: sticky;
  z-index: 5;
  top: 0;
  right: auto;
  display: block;
  max-width: none;
  margin: -6px -6px 12px;
  border-color: #b16b21;
  background: #fff4d8;
  box-shadow: 0 2px 7px rgba(18, 34, 45, 0.24);
}

.toast.dialog-toast[hidden] {
  display: none;
}

dialog {
  width: min(760px, calc(100vw - 42px));
  max-height: calc(100vh - 58px);
  padding: 0;
  overflow: hidden;
  border: 1px solid #657d90;
  border-radius: 5px;
  color: #15242f;
  background: #f4f7f9;
  box-shadow: 7px 9px 28px rgba(13, 29, 42, 0.42);
}

dialog.is-positioned {
  position: fixed;
  inset: auto;
  margin: 0;
}

dialog::backdrop {
  background: rgba(18, 29, 38, 0.35);
  backdrop-filter: blur(2px);
}

.dialog-titlebar {
  display: flex;
  align-items: center;
  min-height: 37px;
  padding: 0 12px;
  border-bottom: 1px solid #7894a8;
  background: rgba(190, 220, 240, 0.96);
  font-weight: 600;
  cursor: move;
  user-select: none;
  touch-action: none;
}

.dialog-body {
  max-height: calc(100vh - 170px);
  padding: 16px;
  overflow-y: auto;
}

.dialog-body > p:first-child {
  margin-top: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #bac6ce;
  background: #e9eef2;
}

.dialog-actions button {
  min-width: 105px;
  padding: 0 13px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(230px, 1.25fr);
  gap: 10px 18px;
  align-items: center;
}

.settings-grid label {
  font-weight: 600;
}

.settings-section {
  margin: 8px 0;
  border: 1px solid #a9b7c0;
  background: rgba(255, 255, 255, 0.34);
}

.settings-section > summary {
  padding: 7px 9px;
  color: #182b38;
  background: #dbe8ef;
  font-weight: 600;
  cursor: pointer;
}

.settings-section > .settings-grid,
.settings-section > p {
  margin: 10px;
}

.settings-grid input[type="range"],
.settings-grid select {
  width: 100%;
}

.settings-grid input[type="number"],
.wide-setting-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 30px;
  padding: 3px 7px;
  border: 1px solid #8397a5;
  border-radius: 3px;
}

.settings-note {
  display: block;
  margin-top: 4px;
  color: #526570;
  font-size: 11px;
  line-height: 1.3;
}

.settings-control {
  display: grid;
  grid-template-columns: auto minmax(110px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.settings-control output {
  min-width: 52px;
  text-align: right;
}

.source-links {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #c7d1d8;
}

.cache-settings {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #c7d1d8;
}

.external-layers {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #c7d1d8;
}

.external-layers h3,
.external-layers p {
  margin: 0;
}

.cache-settings h3,
.cache-settings p {
  margin: 0;
}

.cache-storage-summary,
.cache-settings-actions,
.cache-entry-main,
.cache-entry-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.cache-settings-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cache-settings-list li {
  padding: 8px 10px;
  border: 1px solid #b4c1ca;
  border-radius: 3px;
  background: #fff;
}

.cache-entry-details {
  justify-content: flex-start;
  margin-top: 3px;
  color: #4d626f;
  font-size: 12px;
}

.cache-entry-main button {
  min-width: 105px;
}

.cache-settings-actions {
  justify-content: flex-end;
}

.source-links h3 {
  margin: 0 0 2px;
  font-size: 15px;
}

.source-links a {
  color: #075f9a;
}

.station-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  gap: 8px;
  margin-bottom: 10px;
}

.station-toolbar input {
  width: 100%;
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid #8397a5;
  border-radius: 3px;
}

.station-toolbar button {
  padding: 0 10px;
  white-space: nowrap;
}

.station-cache-options {
  display: grid;
  grid-template-columns: auto minmax(210px, 300px) minmax(220px, 1fr);
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid #bdcbd4;
  background: #edf4f8;
}

.station-cache-options label {
  font-weight: 600;
}

.station-cache-options select {
  min-height: 30px;
}

.station-cache-options small,
.dialog-explanation {
  color: #526570;
  font-size: 11px;
}

.cache-progress-panel {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #8397a5;
  border-radius: 3px;
  background: #eaf2f7;
}

.cache-progress-panel[hidden] {
  display: none;
}

.cache-progress-heading,
.cache-progress-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cache-progress-panel progress {
  width: 100%;
  height: 20px;
  accent-color: #3d83b8;
}

.cache-progress-details {
  color: #405867;
  font-size: 12px;
}

.manual-location-grid {
  display: grid;
  grid-template-columns: minmax(140px, 0.65fr) minmax(300px, 1.7fr);
  gap: 10px 14px;
  align-items: center;
}

.manual-location-grid label {
  font-weight: 600;
}

.manual-location-grid input {
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid #8397a5;
  border-radius: 3px;
}

.manual-location-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.station-list {
  height: min(420px, 48vh);
  margin: 0;
  padding: 3px;
  overflow-y: auto;
  border: 1px solid #8195a3;
  background: #fff;
  list-style: none;
}

.station-list button {
  display: grid;
  grid-template-columns: 55px minmax(220px, 1fr) 178px 98px;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 5px 8px;
  border: 0;
  border-bottom: 1px solid #e0e6ea;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  text-align: left;
}

.station-list button:hover,
.station-list button[aria-selected="true"] {
  background: #dcecf7;
}

.station-list span {
  align-self: start;
  overflow-wrap: anywhere;
}

.station-list .cached {
  color: #247044;
  font-weight: 600;
}

.station-list .not-cached {
  color: #6b7074;
}

.station-empty {
  padding: 18px;
  color: #5c6972;
  text-align: center;
}

@media (max-width: 820px) {
  .app-window {
    grid-template-rows: 34px 30px 39px minmax(0, 1fr) 25px;
  }

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

  .station-toolbar,
  .manual-location-grid,
  .manual-location-action {
    grid-template-columns: 1fr;
  }

  .cache-progress-details {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .station-list button {
    grid-template-columns: 52px 1fr 92px;
  }

  .station-list .coordinates {
    display: none;
  }
}
