 :root {
  --ha-orange: rgb(255, 152, 0);
  --ha-seminar-orange: #F39221;
  --ha-orange-dark: #c96f00;
  --ha-ink: #242424;
  --ha-muted: #666;
  --ha-border: #d9d9d9;
  --ha-bg: #f4f4f3;
  --ha-panel: #fff;
}

* { box-sizing: border-box; }
html { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ha-ink); background: var(--ha-bg); }
body { margin: 0; line-height: 1.55; }
a { color: #1d5f9f; }
a:hover { color: var(--ha-orange-dark); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 70px;
  padding: 0.75rem clamp(1rem, 3vw, 2.5rem);
  background: rgba(255,255,255,0.96);
  border-bottom: 1px solid var(--ha-border);
  backdrop-filter: blur(10px);
}
.brand { display: inline-flex; align-items: center; gap: 0.85rem; color: var(--ha-ink); text-decoration: none; font-weight: 700; }
.brand img { width: auto; height: 42px; object-fit: contain; }
.brand-fallback { color: var(--ha-orange-dark); letter-spacing: 0; }
.top-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--ha-border);
  border-radius: 4px;
  color: var(--ha-ink);
  text-decoration: none;
  background: #fff;
}

.course-layout {
  display: grid;
  grid-template-columns: minmax(220px, 290px) minmax(0, 1fr);
  gap: clamp(1rem, 2.5vw, 2rem);
  max-width: 1380px;
  margin: 0 auto;
  padding: clamp(1rem, 2.5vw, 2rem);
}
.course-nav {
  position: sticky;
  top: 90px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow: auto;
  padding-right: 0.5rem;
}
.course-nav h2 {
  margin: 1.25rem 0 0.35rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--ha-muted);
}
.course-nav ol { list-style: none; margin: 0; padding: 0; }
.course-nav a {
  display: block;
  padding: 0.45rem 0.55rem;
  border-radius: 4px;
  color: var(--ha-ink);
  text-decoration: none;
  font-size: 0.94rem;
}
.course-nav a:hover,
.course-nav a.active { background: #fff0db; color: #6b3f00; }
.nav-home { margin-bottom: 0.75rem; font-weight: 700; border-left: 4px solid var(--ha-orange); background: #fff; }

.content {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--ha-border);
  border-radius: 6px;
  padding: clamp(1rem, 4vw, 3rem);
}
.content h1 { margin-top: 0; font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.15; letter-spacing: 0; }
.content h2 { margin-top: 2.2rem; padding-top: 0.2rem; border-top: 1px solid #ececec; font-size: 1.45rem; letter-spacing: 0; }
.content h3 { margin-top: 1.7rem; font-size: 1.18rem; letter-spacing: 0; }
.content h4, .content h5, .content h6 { margin-top: 1.3rem; letter-spacing: 0; }
.content img { max-width: 100%; height: auto; border: 1px solid var(--ha-border); border-radius: 4px; background: #fff; }
.ha-figure { margin: 1.2rem 0; }

.index-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 3rem);
}
.index-main h1 { margin: 0 0 1.4rem; letter-spacing: 0; }
.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}
.index-grid section {
  background: #fff;
  border: 1px solid var(--ha-border);
  border-radius: 6px;
  padding: 1rem;
}
.index-grid h2 { margin: 0 0 0.65rem; font-size: 1.15rem; }
.index-grid ol { margin: 0; padding-left: 1.25rem; }
.index-grid li + li { margin-top: 0.4rem; }

.ha-uebung pre {
  position: relative;
  background: #1f1f1f;
  color: #f5f5f5;
  padding: 0.95rem 1rem;
  padding-right: 6rem;
  border-radius: 6px;
  overflow-x: hidden;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.94rem;
  line-height: 1.5;
}
.ha-uebung pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.ha-copy-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  padding: 4px 9px;
  border: none;
  border-radius: 4px;
  background: #3a86ff;
  color: #fff;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
}
.ha-copy-btn.copied { background: #2a9d4a; color: #fff; }

.ha-table { border-collapse: collapse; margin: 1rem 0; width: 100%; }
.ha-table th, .ha-table td { border: 1px solid #d0d0d0; padding: 0.45rem 0.7rem; text-align: left; vertical-align: top; }
.ha-table th { background: #2b2b2b; color: #fff; }
.ha-table tbody tr:nth-child(even) { background: #f7f7f7; }

.ha-box {
  border-radius: 6px;
  padding: 0.85rem 1rem 0.85rem 2.7rem;
  margin: 1rem 0;
  position: relative;
  border-left: 5px solid;
}
.ha-box > :first-child { margin-top: 0; }
.ha-box > :last-child { margin-bottom: 0; }
.ha-box::before { position: absolute; left: 0.85rem; top: 0.85rem; font-size: 1.05rem; line-height: 1.2; }
.ha-box-green { background: #e7f6ec; border-color: #2a9d4a; color: #14502a; }
.ha-box-green::before { content: "\01F3C1"; }
.ha-box-red { background: #fdecea; border-color: #d7322b; color: #7a1410; }
.ha-box-red::before { content: "\26A0"; }
.ha-box-orange { background: #fff4e5; border-color: var(--ha-seminar-orange); color: #7a4a08; }
.ha-box-orange::before { content: "\1F4A1"; }
.ha-box-blue { background: #e8f1ff; border-color: #3a86ff; color: #173a63; }
.ha-box-blue::before { content: "\1F4CB"; }

.ha-uebung :not(pre) > code {
  background: #f1f1f1;
  color: #c7254e;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.92em;
}
.ha-ph { background: var(--ha-seminar-orange); color: #1e1e1e; padding: 0 4px; border-radius: 3px; font-weight: 600; }
.ha-ph.ha-ph-filled { background: #2a9d4a; color: #fff; }
.ha-ph-panel {
  background: #fff6e9;
  border: 1px solid #f0c98a;
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
  margin: 1rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.ha-ph-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ha-ph-row label { font-size: 0.92rem; font-weight: 600; color: #7a4a08; }
.ha-ph-row input {
  flex: 1 1 210px;
  min-width: 160px;
  padding: 6px 9px;
  border: 1px solid #cfcfcf;
  border-radius: 4px;
  font: inherit;
}
.ha-ph-row input:focus { outline: 2px solid var(--ha-seminar-orange); border-color: var(--ha-seminar-orange); }
.ha-ph-panel + pre { margin-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }

.ha-cred { display: inline-flex; align-items: center; gap: 4px; }
.ha-cred .ha-cred-val { background: #f1f1f1; color: #c7254e; padding: 1px 6px; border-radius: 3px; }
.ha-cred-copy {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1em;
  line-height: 1;
  padding: 1px 4px;
  border-radius: 3px;
  color: #3a86ff;
}
.ha-cred-copy:hover { background: #e8f0fe; }
.ha-cred-copy.copied { color: #2a9d4a; }

.ha-uebung img { cursor: zoom-in; transition: box-shadow .15s; }
.ha-uebung img:hover { box-shadow: 0 0 0 2px var(--ha-seminar-orange); }
.ha-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0,0,0,0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2vmin;
  cursor: zoom-out;
}
.ha-lightbox img { max-width: 96vw; max-height: 94vh; border-radius: 4px; box-shadow: 0 4px 40px rgba(0,0,0,0.6); }
.ha-lightbox-close { position: fixed; top: 14px; right: 20px; font-size: 34px; line-height: 1; color: #fff; cursor: pointer; user-select: none; }

.page-links {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--ha-border);
}
.page-links a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--ha-border);
  border-radius: 4px;
  background: #fff;
  color: var(--ha-ink);
  text-decoration: none;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: linear-gradient(135deg, #f4f4f3 0%, #fff5e6 100%);
}
.login-shell { width: min(100%, 420px); }
.login-panel {
  background: #fff;
  border: 1px solid var(--ha-border);
  border-radius: 6px;
  padding: 1.5rem;
  box-shadow: 0 18px 50px rgba(0,0,0,0.08);
}
.login-logo { height: 52px; width: auto; margin-bottom: 1rem; }
.login-logo-fallback {
  display: inline-flex;
  align-items: center;
  height: auto;
  min-height: 42px;
  margin-bottom: 1rem;
  color: var(--ha-orange-dark);
  font-weight: 900;
}
.login-panel h1 { margin: 0 0 1rem; font-size: 1.5rem; letter-spacing: 0; }
.login-panel label { display: block; margin: 0.8rem 0; font-weight: 600; }
.login-panel input {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  min-height: 42px;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--ha-border);
  border-radius: 4px;
  font: inherit;
}
.login-panel input:focus { outline: 2px solid var(--ha-orange); border-color: var(--ha-orange); }
.login-panel button {
  width: 100%;
  min-height: 44px;
  margin-top: 0.8rem;
  border: none;
  border-radius: 4px;
  background: var(--ha-orange);
  color: #1f1f1f;
  font-weight: 800;
  cursor: pointer;
}
.login-error {
  margin: 0 0 0.9rem;
  padding: 0.55rem 0.7rem;
  border-left: 4px solid #d7322b;
  background: #fdecea;
  color: #7a1410;
}

@media (max-width: 860px) {
  .site-header { position: static; align-items: flex-start; }
  .brand img { height: 36px; }
  .course-layout { display: block; padding: 0.75rem; }
  .course-nav { position: static; max-height: none; margin-bottom: 1rem; padding-right: 0; }
  .content { padding: 1rem; }
  .page-links { flex-direction: column; }
}
