:root {
  color-scheme: light;
  --ink: #122841;
  --muted: #4a6078;
  --accent: #145fa2;
  --accent-strong: #0e4b85;
  --line: #cddbe7;
  --paper: #fff;
  --wash: #edf4fa;
  --error: #9c2c32;
  font: 100%/1.5 system-ui, sans-serif;
  color: var(--ink);
  background: var(--wash);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--accent-strong); text-underline-offset: .17em; }
p { margin: .45rem 0 1rem; }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: clamp(1.55rem, 3vw, 2rem); letter-spacing: -.025em; }
h2 { font-size: 1.1rem; }
form { margin: 0; }
button, select, input { font: inherit; }
button { cursor: pointer; }
button[hidden] { display: none; }
:focus-visible { outline: 3px solid #0968aa; outline-offset: 3px; }

.skip-link { position: absolute; top: .5rem; left: .5rem; z-index: 1; background: white; padding: .5rem; }
.skip-link:not(:focus) { clip-path: inset(50%); }
.topbar {
  min-height: 4.25rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: .75rem 1.2rem;
  padding: .65rem clamp(1rem, 4vw, 2.5rem);
  background: #102b46;
  color: white;
}
.topbar a, .topbar button { color: white; }
.brand, .account { display: flex; align-items: center; gap: .85rem; }
.brand { text-decoration: none; font-size: 1.12rem; font-weight: 720; }
.brand-icon, .avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #d7edff;
  color: #155383;
  font-weight: 700;
}
.brand-icon { border-radius: .65rem; background: #91d6f8; color: #0d365a; }
.account { font-size: .9rem; }
.quiet { background: transparent; padding: .35rem .65rem; border: 1px solid #66839c; border-radius: .5rem; }
.topbar :focus-visible { outline-color: #9ee2ff; }

.workspace { display: grid; grid-template-columns: minmax(15rem, 19rem) minmax(0, 1fr); min-height: calc(100vh - 4.25rem); }
.sidebar { background: var(--paper); border-right: 1px solid var(--line); padding: 1.25rem 1rem; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1.1rem; }
.profile-list { display: grid; gap: .25rem; }
.profile-list a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem;
  border-radius: .7rem;
  color: var(--ink);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.profile-list a:hover, .profile-list a[aria-current] { background: #e6f2fd; }
.profile-list a[aria-current] { box-shadow: inset 3px 0 var(--accent); font-weight: 700; }
.thread { min-width: 0; }
.thread-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 1.15rem clamp(1rem, 4vw, 2.5rem);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.muted { color: var(--muted); font-size: .9rem; margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.primary, .small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  padding: .4rem .8rem;
  border: 1px solid var(--line);
  border-radius: .6rem;
  background: var(--paper);
  color: var(--accent-strong);
  font-size: .9rem;
  font-weight: 650;
  text-decoration: none;
}
.small-button:hover { background: var(--wash); }
.primary { background: var(--accent); border-color: var(--accent); color: white; }
.primary:hover { background: var(--accent-strong); }
.messages { max-width: 56rem; padding: 1.4rem clamp(1rem, 4vw, 2.5rem) 2rem; }
.message {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: .3rem 1rem 1rem 1rem;
  margin-bottom: 1rem;
  padding: 1rem 1.2rem;
  overflow-wrap: anywhere;
}
.message header { display: flex; align-items: center; gap: .55rem; margin-bottom: .65rem; }
.message time { margin-left: auto; font-size: .875rem; color: var(--muted); }
.message p { margin-bottom: 0; }
.digest div { white-space: pre-wrap; }
.digest a { display: block; }
.digest-space { height: .7rem; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: clamp(1rem, 4vw, 2rem);
  margin: clamp(1rem, 5vw, 3rem) auto;
  width: calc(100% - 2rem);
  max-width: 45rem;
  box-shadow: 0 .4rem 1.6rem #102b460a;
}
.auth { max-width: 29rem; }
.auth form { display: grid; gap: .75rem; margin: 1.3rem 0; }
.auth ol { padding-left: 1.4rem; }
.auth li { margin-bottom: .5rem; }
label, legend { display: block; font-size: .95rem; font-weight: 650; }
input:not([type="checkbox"], [type="hidden"]), select {
  width: 100%;
  min-height: 2.65rem;
  padding: .45rem .65rem;
  border: 1px solid #93aac0;
  border-radius: .5rem;
  background: white;
  color: var(--ink);
}
select {
  appearance: none;
  padding-right: 2rem;
  background: linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 1rem) 50% / .35rem .35rem no-repeat,
              linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - .65rem) 50% / .35rem .35rem no-repeat;
}
input[type="checkbox"] { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }
small { display: block; color: var(--muted); font-size: .875rem; margin-top: .25rem; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; margin: 1.25rem 0; }
.fields label { margin-bottom: .25rem; }
fieldset { margin: 0; padding: .35rem .6rem; border: 1px solid var(--line); border-radius: .5rem; }
fieldset label { font-weight: 400; }
.toggle { display: flex; align-items: center; gap: .4rem; }
.toggle label { margin: 0; }
.error, .errorlist, .danger { color: var(--error); }
.errorlist { margin: .3rem 0; padding-left: 1.15rem; }
.settings h2, .settings > form, .invite { margin-top: 1.1rem; }
.invite { display: grid; gap: .5rem; }
.guest-list { list-style: none; padding: 0; margin-bottom: 0; }
.guest-list li { padding: .75rem 0; border-top: 1px solid var(--line); }
.guest-list summary { cursor: pointer; color: var(--accent-strong); }

@media (max-width: 47rem) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: .75rem 1rem; }
  .sidebar-header { margin-bottom: .5rem; }
  .profile-list { display: flex; overflow: auto; padding: .2rem; }
  .profile-list a { flex: 0 0 auto; max-width: 80vw; }
}

@media (max-width: 34rem) {
  .fields { grid-template-columns: 1fr; }
  .topbar { gap: .65rem; }
  .account { gap: .5rem; }
  .message { padding: .8rem; }
}
