:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #2563eb;
  --red: #dc2626;
  --amber: #d97706;
  --green: #059669;
  --font: 'Inter', system-ui, sans-serif;
  --display: 'Newsreader', Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body.hd-app {
  margin: 0;
  min-height: 100%;
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  color: var(--ink);
  font-family: var(--font);
  background: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

.hd-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.4rem;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
}

.hd-mark {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.55rem;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
}

.hd-rail nav {
  display: grid;
  gap: 0.35rem;
  width: 100%;
  justify-items: center;
}

.hd-rail nav a {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.5rem;
  color: #94a3b8;
  font-size: 1rem;
}

.hd-rail nav a:hover,
.hd-rail nav a.is-on {
  background: rgba(37, 99, 235, 0.25);
  color: #fff;
}

.hd-shell {
  min-width: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) 1fr;
}

@media (max-width: 860px) {
  .hd-shell {
    grid-template-columns: 1fr;
  }

  .hd-shell.is-detail .hd-list {
    display: none;
  }

  .hd-shell.is-list .hd-detail {
    display: none;
  }
}

.hd-list {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.hd-list__head {
  padding: 0.95rem 1rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.hd-list__head h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.hd-list__head p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.hd-search {
  margin-top: 0.7rem;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.5rem 0.7rem;
  font: inherit;
  font-size: 0.86rem;
  outline: none;
  background: #f9fafb;
}

.hd-search:focus {
  border-color: #93c5fd;
  background: #fff;
}

.hd-items {
  overflow: auto;
  flex: 1;
}

.hd-item {
  display: block;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
}

.hd-item:hover {
  background: #f8fafc;
}

.hd-item.is-active {
  background: #eff6ff;
  border-left-color: var(--blue);
}

.hd-item.is-hidden {
  display: none;
}

.hd-item__top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.hd-item__id {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: 0.02em;
}

.hd-item__time {
  font-size: 0.7rem;
  color: var(--muted);
}

.hd-item__subject {
  font-weight: 650;
  font-size: 0.9rem;
  line-height: 1.3;
}

.hd-item__sub {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.hd-item__flags {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.45rem;
}

.hd-pill {
  display: inline-flex;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.hd-pill--urgent {
  background: #fee2e2;
  color: var(--red);
}
.hd-pill--high {
  background: #ffedd5;
  color: var(--amber);
}
.hd-pill--normal,
.hd-pill--low {
  background: #f3f4f6;
  color: var(--muted);
}
.hd-pill--open,
.hd-pill--new {
  background: #dbeafe;
  color: var(--blue);
}
.hd-pill--waiting {
  background: #ffedd5;
  color: var(--amber);
}
.hd-pill--resolved {
  background: #d1fae5;
  color: var(--green);
}

.hd-detail {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
}

.hd-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}

.hd-empty strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 600;
}

.hd-detail__head {
  padding: 1rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.hd-detail__head .hd-item__flags {
  margin-top: 0;
  margin-bottom: 0.55rem;
}

.hd-detail__head h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.hd-detail__meta {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.hd-thread {
  flex: 1;
  overflow: auto;
  padding: 1rem 1.25rem 1.5rem;
  display: grid;
  gap: 0.75rem;
  align-content: start;
}

.hd-msg {
  max-width: 42rem;
  padding: 0.9rem 1rem;
  border-radius: 0.85rem;
  background: var(--panel);
  border: 1px solid var(--line);
}

.hd-msg--agent {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.hd-msg--note {
  border-style: dashed;
  background: #f0fdf4;
}

.hd-msg__who {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.hd-msg__body {
  margin-top: 0.4rem;
  font-size: 0.94rem;
  line-height: 1.55;
}

.hd-sidefacts {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
  font-size: 0.84rem;
}

.hd-sidefacts div {
  display: flex;
  gap: 0.75rem;
}

.hd-sidefacts dt {
  width: 5.5rem;
  color: var(--muted);
  flex-shrink: 0;
}

@media (max-width: 860px) {
  body.hd-app {
    grid-template-columns: 1fr;
  }

  .hd-rail {
    min-height: auto;
    flex-direction: row;
    justify-content: flex-start;
    padding: 0.55rem 0.75rem;
  }

  .hd-rail nav {
    display: flex;
    width: auto;
  }
}
