/* ── CSS Custom Properties ── */
:root {
  --primary:       #000080;
  --primary-light: #0000c0;
  --sidebar-bg:    #000040;
  --sidebar-head:  #0000c0;
  --sidebar-link:  #ffffff;
  --sidebar-hover: #ffff00;
  --accent-red:    #800000;
  --link:          #4040ff;
  --bg:            #ffffff;
  --text:          #000000;
  --titles:        #101010;
  --border:        rgba(0, 0, 0, .15);
  --sidebar-width:  14rem;
  --header-height:  3.5rem;
}

[data-theme="dark"] {
  --bg:     #1c1c2e;
  --text:   #e0e0e0;
  --titles: #ffffff;
  --link:   #8080ff;
  --border: rgba(255, 255, 255, .15);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Layout ── */
html, body { height: 100%; }

body {
  font-family: "Work Sans", Helvetica, Arial, sans-serif;
  font-weight: 300;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* ── Header ── */
.site-header {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  align-items: center;
  height: var(--header-height);
  background: var(--sidebar-head);
  border-bottom: 3px solid var(--accent-red);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-title {
  color: var(--sidebar-link);
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: .06em;
  padding: .75rem 1.25rem;
}

.site-title:hover { color: var(--sidebar-hover); }

.page-heading {
  padding: .75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255,255,255,.9);
  letter-spacing: .03em;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  padding: .5rem 0;
  flex: 1;
}

.sidebar nav a {
  color: var(--sidebar-link);
  text-decoration: none;
  padding: .5rem 1.25rem;
  font-size: .95rem;
  font-weight: 400;
  transition: background .12s, color .12s;
}

.sidebar nav a:hover,
.sidebar nav a[aria-current="page"] {
  background: var(--accent-red);
  color: var(--sidebar-hover);
}

.sidebar-footer {
  padding: .75rem 1.25rem;
  color: rgba(255,255,255,.7);
  font-size: .85rem;
  border-top: 1px solid rgba(255,255,255,.2);
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.lang-switcher {
  display: flex;
  gap: .6rem;
  align-items: center;
  margin-bottom: .15rem;
}

.lang-active {
  color: rgba(255,255,255,.95);
  font-weight: 600;
  font-size: .95rem;
}

.lang-link {
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: .95rem;
  transition: color .12s;
}

.lang-link:hover {
  color: rgba(255,255,255,1);
}

.footer-link {
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: .85rem;
  transition: color .12s;
}

.footer-link:hover {
  color: rgba(255,255,255,1);
}

/* ── Content ── */
.content-wrapper {
  min-width: 0;
}

main {
  max-width: 860px;
  padding: 2.5rem 2rem 4rem;
}

/* ── Typography ── */
h1 {
  font-size: 2rem;
  font-weight: 300;
  color: var(--primary);
  margin: 0 0 1.25rem 0;
  letter-spacing: .01em;
}

[data-theme="dark"] h1 { color: var(--primary-light); }

h2 { font-size: 1.8rem; font-weight: 500; color: var(--titles); margin: 2rem 0 .75rem; }
h3 { font-size: 1.4rem; font-weight: 500; color: var(--titles); margin: 1.75rem 0 .5rem; }

p { margin: 0 0 1rem; text-align: justify; }

ul, ol { margin: 0 0 1rem; padding-left: 1.5rem; }
li { margin-bottom: .3rem; }

a { color: var(--link); }
a:hover { color: var(--accent-red); }

/* ── Blockquote ── */
blockquote {
  background: rgba(0, 0, 64, .06);
  border-left: 4px solid var(--accent-red);
  padding: .85rem 1.25rem;
  margin: 1.5rem 0;
  font-style: italic;
}

[data-theme="dark"] blockquote { background: rgba(0, 0, 64, .3); }

blockquote p { margin: 0; }
blockquote p + p {
  margin-top: .5rem;
  font-style: normal;
  font-weight: 500;
  opacity: .65;
}

/* ── Collapsible sections ── */
details.tool-collapsible {
  margin: 0 0 1.5rem;
  border: 1px solid var(--border);
}

details.tool-collapsible summary {
  padding: .65rem 1rem;
  background: rgba(0, 0, 128, .06);
  font-weight: 500;
  font-size: 1.05rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .6rem;
}

details.tool-collapsible summary::before {
  content: '▶';
  font-size: .7rem;
  color: var(--accent-red);
  transition: transform .15s;
  flex-shrink: 0;
}

details.tool-collapsible[open] summary::before {
  transform: rotate(90deg);
}

details.tool-collapsible summary:hover {
  background: rgba(0, 0, 128, .1);
}

details.tool-collapsible > table,
details.tool-collapsible > .tool-table {
  margin-top: 0;
}

/* ── Code blocks ── */
pre {
  background: rgba(0, 0, 64, .05);
  border-left: 3px solid var(--primary);
  padding: .75rem 1rem;
  margin: .75rem 0 1rem;
  overflow-x: auto;
  font-size: .88rem;
  line-height: 1.55;
}

[data-theme="dark"] pre { background: rgba(0, 0, 64, .25); }

code {
  font-family: "Consolas", "Fira Mono", "Courier New", monospace;
}

pre code { background: none; padding: 0; }

:not(pre) > code {
  background: rgba(0, 0, 128, .08);
  padding: .1em .35em;
  font-size: .9em;
}

/* ── Header buttons ── */
.menu-toggle { display: none; }

/* ── Theme switcher (sidebar footer) ── */
.theme-switcher {
  display: flex;
  gap: .6rem;
  align-items: center;
  margin-bottom: .15rem;
}

.theme-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

.theme-btn.lang-active { cursor: default; }

/* ── Sidebar sub-nav ── */
.nav-section {
  display: block;
  padding: .2rem 1.25rem;
  color: rgba(255, 255, 255, .7);
  font-size: .85rem;
  font-weight: 600;
  margin-top: .2rem;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, .2);
  border-bottom: 1px solid rgba(255, 255, 255, .2);
}

.sidebar nav a.nav-sub {
  padding-left: 1.25rem;
  font-size: .95rem;
  color: rgba(255, 255, 255, .85);
}

.sidebar nav a.nav-sub:hover {
  background: var(--accent-red);
  color: var(--sidebar-hover);
}

/* ── Tool pages ── */
.tool-section { margin: 0 0 2.5rem; }

.big-number {
  font-size: 3rem;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  color: var(--primary);
  margin: .4rem 0 .2rem;
  line-height: 1.1;
}

[data-theme="dark"] .big-number { color: var(--primary-light); }

.tool-input-row {
  display: flex;
  gap: .6rem;
  align-items: center;
  flex-wrap: wrap;
  margin: .6rem 0;
}

.tool-input-row input,
.tool-input-row select {
  padding: .4rem .6rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: .95rem;
}

.tool-input-row input[type="number"],
.tool-input-row input[type="datetime-local"] { width: 15rem; }

.btn {
  padding: .4rem 1rem;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 500;
}

.btn:hover { background: var(--accent-red); }

/* ── KaTeX eagle emoji hack ── */
.k-eagle {
  position: relative;
}
.k-eagle::before {
  content: "🦅";
  position: absolute;
  left: 0;
  top: -0.1em;
  font-size: 0.85em;
  line-height: 1;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}

/* ── Content tables (markdown-rendered) ── */
main table {
  border-collapse: collapse;
  width: 100%;
  font-size: .9rem;
  margin: .75rem 0 1.5rem;
}

main table th {
  background: rgba(0, 0, 128, .08);
  color: var(--titles);
  font-weight: 600;
  text-align: left;
  padding: .45rem .75rem;
  border-bottom: 2px solid var(--primary);
}

main table td {
  padding: .4rem .75rem;
  border-bottom: 1px solid rgba(128, 128, 128, .15);
}

main table tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, .03);
}

[data-theme="dark"] main table th { background: rgba(0, 0, 128, .2); }
[data-theme="dark"] main table tbody tr:nth-child(even) td { background: rgba(255, 255, 255, .04); }

main table tr:hover td { background: rgba(0, 0, 128, .06); }

table.tool-table {
  border-collapse: collapse;
  width: 100%;
  font-size: .9rem;
  margin: .75rem 0;
}

table.tool-table th {
  background: rgba(0, 0, 128, .08);
  color: var(--titles);
  font-weight: 600;
  text-align: left;
  padding: .45rem .75rem;
  border-bottom: 2px solid var(--primary);
}

table.tool-table td {
  padding: .35rem .75rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

table.tool-table tr:hover td { background: rgba(134, 134, 134, .05); }

.ms-passed { color: rgba(134, 134, 134, .6); }
.ms-future { color: var(--accent-red); font-weight: 500; }

.countdown-display {
  font-size: 1.6rem;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  color: var(--accent-red);
  margin: .5rem 0;
}

/* ── Zeitzonen world clock ── */
.city-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
  margin: 1rem 0;
}

.city-card {
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  padding: .65rem .9rem;
}

.city-name {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(134, 134, 134, 1);
}

.city-time {
  font-size: 1.7rem;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  color: var(--titles);
  line-height: 1.2;
}

.city-date { font-size: .78rem; color: rgba(134, 134, 134, .9); }
.city-offset { font-size: .72rem; color: var(--accent-red); margin-top: .15rem; }

/* ── Converter ── */
.conv-category-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.conv-category-row label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(134,134,134,.9);
  white-space: nowrap;
}

.conv-category-select {
  flex: 1;
  padding: .55rem .85rem;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--primary);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}

.conv-category-select:focus {
  border-bottom-color: var(--accent-red);
}

.conv-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: start;
}

.conv-card {
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  padding: 1.25rem 1.25rem 1rem;
  background: rgba(0, 0, 128, .02);
}

[data-theme="dark"] .conv-card { background: rgba(0, 0, 128, .1); }

.conv-card-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(134,134,134,.8);
  margin-bottom: .6rem;
}

.conv-value {
  display: block;
  width: 100%;
  font-size: 2.4rem;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  color: var(--primary);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
  font-family: inherit;
  padding: .1rem 0 .4rem;
  margin-bottom: .85rem;
}

[data-theme="dark"] .conv-value { color: var(--primary-light); }

.conv-value:focus {
  border-bottom-color: var(--primary);
}

.conv-value::placeholder {
  color: rgba(134,134,134,.35);
  font-size: 1.8rem;
}

.conv-unit-select {
  width: 100%;
  padding: .45rem .6rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: .92rem;
  cursor: pointer;
  outline: none;
}

.conv-unit-select:focus {
  border-color: var(--primary);
}

.conv-swap-col {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 3.8rem;
}

.conv-swap {
  background: none;
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 2.4rem;
  height: 2.4rem;
  font-size: 1.1rem;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, border-color .12s, color .12s;
  flex-shrink: 0;
}

.conv-swap:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.conv-note {
  font-size: .8rem;
  opacity: .55;
  margin-top: .85rem;
}

@media (max-width: 48rem) {
  .conv-grid {
    grid-template-columns: 1fr;
  }
  .conv-swap-col {
    padding-top: 0;
    transform: rotate(90deg);
  }
  .conv-value { font-size: 1.8rem; }
}

/* ── Clocks (Spaß) ── */
.clock-display {
  font-size: 4.5rem;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
  color: var(--primary);
  margin: .3rem 0;
  line-height: 1;
}

[data-theme="dark"] .clock-display { color: var(--primary-light); }

.clock-label {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(134, 134, 134, .8);
  margin-bottom: .25rem;
}

/* ── Sun times ── */
.sun-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: .6rem;
  margin: 1rem 0;
}

.sun-item {
  border-left: 3px solid var(--accent-red);
  padding: .4rem .75rem;
  background: rgba(0, 0, 64, .04);
}

[data-theme="dark"] .sun-item { background: rgba(0, 0, 64, .2); }

.sun-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(134, 134, 134, .9);
}

.sun-value {
  font-size: 1.25rem;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}

/* ── Zeitzonen-Datenbank ── */
.tz-db-regions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: 1rem;
}

.tz-region-btn {
  padding: .35rem .85rem;
  border: 1px solid var(--border);
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}

.tz-region-btn:hover { background: rgba(0,0,128,.08); }

.tz-region-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tz-db-main {
  display: grid;
  grid-template-columns: 185px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.tz-db-city-list {
  border: 1px solid var(--border);
  max-height: 420px;
  overflow-y: auto;
}

.tz-city-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: .38rem .75rem;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: .88rem;
  cursor: pointer;
  transition: background .1s;
}

.tz-city-btn:last-child { border-bottom: none; }
.tz-city-btn:hover { background: rgba(0,0,128,.06); }

.tz-city-btn.active {
  background: rgba(0,0,128,.1);
  font-weight: 500;
  border-left: 3px solid var(--primary);
  padding-left: calc(.75rem - 2px);
}

.tz-db-profile {
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  padding: 1rem 1.25rem 1.25rem;
  min-height: 160px;
}

.tz-profile-empty {
  color: rgba(134,134,134,.6);
  font-size: .9rem;
  padding: 2.5rem 0;
  text-align: center;
}

.tz-profile-name {
  font-size: 2rem;
  font-weight: 200;
  color: var(--primary);
  line-height: 1.1;
  margin-bottom: .15rem;
}

[data-theme="dark"] .tz-profile-name { color: var(--primary-light); }

.tz-profile-tz-id {
  font-family: "Consolas", "Fira Mono", monospace;
  font-size: .82rem;
  color: rgba(134,134,134,.85);
  margin-bottom: .85rem;
}

.tz-profile-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .2rem .8rem;
  font-size: .88rem;
  margin-bottom: 1.25rem;
}

.tz-profile-facts dt {
  font-weight: 500;
  color: rgba(134,134,134,.85);
  white-space: nowrap;
}

.tz-chart-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: rgba(134,134,134,.8);
  margin: 1rem 0 .35rem;
}

.tz-chart-wrap { position: relative; }

.tz-chart-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.tz-chart-line {
  stroke: var(--primary);
  stroke-width: 2;
  fill: none;
}

[data-theme="dark"] .tz-chart-line { stroke: var(--primary-light); }

/* ── Mobile ── */
@media (max-width: 48rem) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .site-header {
    grid-template-columns: auto 1fr auto;
  }

  .page-heading { font-size: .85rem; }

  /* Hamburger button */
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: rgba(255, 255, 255, .9);
    font-size: 1.3rem;
    padding: .75rem 1rem;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
  }

  .menu-toggle:hover { color: var(--sidebar-hover); }

  /* Sidebar as fixed overlay — doesn't push content, works in landscape */
  .sidebar {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    height: auto;
    overflow-y: auto;
    flex-direction: column;
  }

  .sidebar.is-open { display: flex; }

  main { padding: 1.5rem 1.25rem 3rem; }

  .big-number { font-size: 2rem; }
  .clock-display { font-size: 3rem; }

  .tz-db-main { grid-template-columns: 1fr; }
  .tz-db-city-list { max-height: 220px; }
}

/* Landscape-Phones: kompaktes Menü hinter Hamburger (auch breite Geräte > 48rem) */
@media (orientation: landscape) and (max-height: 30rem) {
  :root { --header-height: 2.75rem; }

  .layout { grid-template-columns: 1fr; }
  .site-header { grid-template-columns: auto 1fr auto auto; }
  .site-title { font-size: 1rem; padding: .5rem 1rem; }
  .page-heading { display: none; }
  .menu-toggle { padding: .5rem .85rem; }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: rgba(255, 255, 255, .9);
    font-size: 1.3rem;
    padding: .5rem .85rem;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
  }

  .sidebar {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    height: auto;
    overflow-y: auto;
    flex-direction: column;
  }

  .sidebar.is-open { display: flex; }

  .sidebar nav a { padding: .35rem 1.25rem; }
  .sidebar-footer { padding: .5rem 1.25rem; }

  main { padding: 1rem 1.25rem 2rem; }
}
