/* Port Search — design system carried over from PTS (Precision Timing Schedule)
   Red header, dark accents, light card-based content, mobile-first. */
:root {
  --header-red: #B71C1C;
  --accent-grey: #424242;
  --content-bg: #F5F5F5;
  --card-bg: #FFFFFF;
  --text-on-dark: #FFFFFF;
  --text-body: rgba(0, 0, 0, 0.87);
  --text-muted: #757575;
  --border-light: #E0E0E0;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--content-bg);
  color: var(--text-body);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- App bar ---------- */
.app-bar {
  background: var(--header-red);
  color: var(--text-on-dark);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  min-height: 56px;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.app-bar-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.app-bar-pill {
  padding: 5px 10px;
  border: 1px solid var(--text-on-dark);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

/* ---------- Layout ---------- */
main {
  padding: 0;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.screen {
  padding: 0 10px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.screen.hidden {
  display: none;
}

.hint {
  padding: 10px 4px 4px;
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- Search toolbar ---------- */
.search-toolbar {
  background: var(--content-bg);
  padding: 12px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 1.05rem;
  border: 2px solid var(--border-light);
  border-radius: 8px;
  background: var(--card-bg);
  box-sizing: border-box;
}

.search-input:focus {
  outline: none;
  border-color: var(--header-red);
}

/* ---------- Results ---------- */
.results-meta {
  padding: 4px 6px 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.results-list {
  padding: 8px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* ---------- Code legend (pinned key above the list) ---------- */
.legend-card {
  flex-shrink: 0;
  margin: 8px 0 4px;
}

.legend-card .port-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-body);
}

.port-card {
  background: var(--card-bg);
  border: 1px solid var(--header-red);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.port-code {
  font-weight: 700;
  font-size: 1rem;
  color: var(--header-red);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  background: rgba(183, 28, 28, 0.06);
  border-radius: 6px;
  padding: 6px 10px;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 3.5rem;
}

.port-code-alt {
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.port-info {
  flex: 1;
  min-width: 0;
}

.port-name {
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.3;
}

.port-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.port-type-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(66, 66, 66, 0.08);
  color: var(--accent-grey);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.results-empty {
  margin: 32px 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
}

/* Highlight matched substring in results */
mark {
  background: rgba(255, 179, 0, 0.4);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
