:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  background: #f4f7fb;
  color: #1d2735;
  --brand: #22324a;
  --accent: #0f8b8d;
  --danger: #b42318;
  --muted: #667085;
  --line: #d9e2ee;
  --surface: #ffffff;
  --surface-soft: #eef4f8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #e9f1f6 0, #f7f9fc 42%, #f4f7fb 100%);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

.topbar {
  min-height: 72px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 2px 14px rgba(23, 38, 55, 0.18);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar p {
  margin: 2px 0 0;
  color: #c8d8e8;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar > div:not(.top-actions) {
  min-width: 0;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 34px;
  line-height: 1;
}

.top-action-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 11px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.top-actions {
  display: inline-flex;
  gap: 8px;
}

@media (max-width: 420px) {
  .topbar {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    gap: 8px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .top-action-button {
    min-height: 40px;
    padding: 0 8px;
    font-size: 12px;
  }

  .top-actions {
    gap: 6px;
  }
}

main {
  width: min(840px, 100%);
  margin: 0 auto;
  padding: 18px 14px 28px;
  flex: 1;
}

.hidden {
  display: none !important;
}

.view {
  min-height: calc(100vh - 120px);
}

.empty-state {
  min-height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 28px 18px;
}

.empty-state img {
  width: 92px;
  height: 92px;
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(32, 45, 62, 0.16);
}

.empty-state h2 {
  margin: 8px 0 0;
  font-size: 24px;
}

.empty-state p {
  max-width: 460px;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.primary-action,
.secondary-action,
.refresh-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

.primary-action {
  color: #ffffff;
  background: var(--accent);
}

.help-text {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.secondary-action,
.refresh-button {
  color: var(--brand);
  background: #dce9f2;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 12px;
}

.list-header h2 {
  margin: 0;
  font-size: 18px;
}

.list-header span {
  color: var(--muted);
  font-size: 14px;
}

.list {
  display: grid;
  gap: 10px;
}

.row-button {
  width: 100%;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  text-align: left;
  padding: 12px;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 20px rgba(31, 49, 67, 0.06);
  cursor: pointer;
}

.row-button img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.row-button strong {
  display: block;
  font-size: 16px;
  line-height: 1.25;
}

.row-button small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.row-button .chevron {
  color: #9aa8b5;
  font-size: 28px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #e9f7f5;
  color: #08706e;
  font-size: 12px;
  font-weight: 700;
}

dialog {
  width: min(440px, calc(100% - 28px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(12, 25, 39, 0.32);
}

dialog::backdrop {
  background: rgba(16, 31, 49, 0.55);
}

.door-dialog {
  position: relative;
  padding: 22px;
  background: var(--surface);
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--brand);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.door-dialog h2 {
  margin: 4px 44px 4px 0;
  font-size: 22px;
}

.door-meta {
  margin: 0 0 14px;
  color: var(--muted);
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.status-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.permission-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  color: #7a2e0e;
  background: #fff1df;
}

.command-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.command-button {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbfd;
  color: var(--brand);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  cursor: pointer;
}

.command-button img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.command-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  filter: grayscale(1);
}

.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 10;
}

.toast {
  max-width: min(440px, calc(100vw - 28px));
  border-radius: 8px;
  padding: 12px 14px;
  color: #ffffff;
  background: #172635;
  box-shadow: 0 12px 28px rgba(18, 32, 48, 0.24);
}

@media (min-width: 720px) {
  main {
    padding-top: 28px;
  }

  .topbar {
    grid-template-columns: 56px 1fr 56px;
    padding-left: max(22px, calc((100vw - 840px) / 2));
    padding-right: max(22px, calc((100vw - 840px) / 2));
  }
}
