/* Kāhu — Science in Flight.
   Colours come from the logo: deep teal wings, mid teal feathers and
   ripples, an orange beak and dots, on white. */
:root {
  --teal-deep: #0f4c5c;
  --teal-deeper: #0a3743;
  --teal: #3a9aae;
  --teal-soft: #e8f3f6;
  --teal-wash: #f4f9fa;
  --orange: #f2a33a;
  --orange-dark: #c97f1c;
  --orange-soft: #fdf1df;

  --bg: #ffffff;
  --ink: #1d2b30;
  --muted: #5b6b70;
  --line: #d5e4e8;
  --line-soft: #e8f0f2;
  --card: #ffffff;
  --danger: #b4412e;
  --danger-soft: #fbeae6;
  --success: #2b7a4b;
  --success-soft: #e6f4ec;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(15, 76, 92, 0.06), 0 2px 6px rgba(15, 76, 92, 0.06);
  --shadow: 0 2px 4px rgba(15, 76, 92, 0.05), 0 10px 28px rgba(15, 76, 92, 0.1);
  --ring: 0 0 0 3px rgba(58, 154, 174, 0.35);

  --font-display: "Poppins", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-body: "Source Sans 3", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 17px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--teal-deep); line-height: 1.25; margin: 0 0 0.6rem; }
h2 { font-size: 1.45rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
a { color: var(--teal-deep); }
a:hover { color: var(--teal); }
p { margin: 0 0 0.8rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  font: 600 0.95rem var(--font-body);
  padding: 0.55rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: #fff; color: var(--teal-deep);
  cursor: pointer; text-decoration: none; transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--teal-wash); border-color: var(--teal); color: var(--teal-deep); }
.btn:focus-visible, input:focus, textarea:focus, select:focus { outline: none; box-shadow: var(--ring); }
.btn.primary { background: var(--teal-deep); border-color: var(--teal-deep); color: #fff; }
.btn.primary:hover { background: var(--teal-deeper); }
.btn.accent { background: var(--orange); border-color: var(--orange); color: #3a2405; }
.btn.accent:hover { background: var(--orange-dark); border-color: var(--orange-dark); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.small { padding: 0.3rem 0.65rem; font-size: 0.85rem; }
.btn.link { border: none; background: none; padding: 0.3rem 0.4rem; }
.btn.link:hover { background: var(--teal-wash); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.icon-btn { border: none; background: none; color: var(--muted); cursor: pointer; padding: 0.3rem 0.45rem; border-radius: 6px; font-size: 0.9rem; }
.icon-btn:hover { background: var(--teal-wash); color: var(--teal-deep); }
.icon-btn.on { color: var(--orange-dark); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; color: var(--teal-deep); }
input, textarea, select {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink);
  padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
}
textarea { min-height: 7rem; resize: vertical; }
input[type="checkbox"] { width: auto; }
.check { display: flex; gap: 0.5rem; align-items: center; font-weight: 400; color: var(--ink); }
.form-row { margin-bottom: 0.9rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-hint { font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; }
.form-actions { display: flex; gap: 0.6rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 0.5rem; }
.stack > * + * { margin-top: 0.8rem; }
.msg { min-height: 1.3em; margin: 0.6rem 0 0; font-size: 0.92rem; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--success); }

.notice { display: grid; grid-template-columns: auto 1fr; gap: 0.7rem; padding: 0.8rem 1rem; border-radius: var(--radius-sm); background: var(--teal-soft); text-align: left; }
.notice > i { color: var(--teal-deep); margin-top: 0.2rem; }
.notice.success { background: var(--success-soft); }
.notice.success > i { color: var(--success); }
.notice.warn { background: var(--orange-soft); }
.notice.warn > i { color: var(--orange-dark); }

/* ---------- Boot & sign in ---------- */
.boot-view { min-height: 100vh; display: grid; place-items: center; color: var(--teal); font-size: 2rem; }
.login-view {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(ellipse at 50% 0%, var(--teal-soft), #fff 60%);
}
.login-card {
  width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow); padding: 2rem 1.8rem; text-align: center;
}
.login-card .logo { width: 210px; height: auto; margin: 0 auto 0.8rem; display: block; }
.login-card .tagline { color: var(--muted); margin-bottom: 1.4rem; }
.login-card .form-row { text-align: left; }

/* ---------- App shell ---------- */
.app-head { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.topbar { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 16px; gap: 1rem; }
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.brand img { width: 58px; height: auto; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; color: var(--teal-deep); line-height: 1; }
.brand-sub { display: block; font-family: var(--font-body); font-weight: 600; font-size: 0.75rem; color: var(--teal); letter-spacing: 0.02em; margin-top: 0.2rem; }

.user-menu { position: relative; }
.user-menu-button { display: flex; align-items: center; gap: 0.5rem; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 0.35rem 0.8rem 0.35rem 0.4rem; cursor: pointer; font: inherit; color: var(--ink); }
.user-menu-button:hover { border-color: var(--teal); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--teal-deep); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 0.8rem; flex: none; }
.avatar.small { width: 26px; height: 26px; font-size: 0.72rem; }
.who { text-align: left; line-height: 1.15; }
.who-name { display: block; font-weight: 600; font-size: 0.92rem; }
.who-role { display: block; font-size: 0.75rem; color: var(--muted); }
.user-menu-panel { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); min-width: 190px; padding: 0.3rem; }
.user-menu-item { display: flex; gap: 0.6rem; align-items: center; width: 100%; border: none; background: none; font: inherit; padding: 0.55rem 0.7rem; border-radius: 6px; cursor: pointer; color: var(--ink); text-align: left; }
.user-menu-item:hover { background: var(--teal-wash); }
.user-menu-item i { width: 1.1rem; color: var(--teal); }

.tabs { max-width: 1180px; margin: 0 auto; display: flex; gap: 0.2rem; padding: 0 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: none; background: none; font: 600 0.98rem var(--font-body); color: var(--muted); padding: 0.7rem 0.95rem 0.75rem; cursor: pointer; border-bottom: 3px solid transparent; display: flex; align-items: center; gap: 0.45rem; white-space: nowrap; }
.tab:hover { color: var(--teal-deep); }
.tab.active { color: var(--teal-deep); border-bottom-color: var(--orange); }
.tab i { color: var(--teal); }

.content { max-width: 1180px; margin: 0 auto; padding: 1.6rem 16px 4rem; }
.panel { display: none; }
.panel.active { display: block; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.section-head h2, .section-head h3 { margin: 0; }
.section-head .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.subtabs { display: flex; gap: 0.4rem; margin-bottom: 1.3rem; flex-wrap: wrap; }
.subtab { border: 1px solid var(--line); background: #fff; color: var(--muted); font: 600 0.92rem var(--font-body); padding: 0.45rem 1rem; border-radius: 999px; cursor: pointer; display: inline-flex; gap: 0.45rem; align-items: center; }
.subtab:hover { border-color: var(--teal); color: var(--teal-deep); }
.subtab.active { background: var(--teal-deep); border-color: var(--teal-deep); color: #fff; }
.subpanel { display: none; }
.subpanel.active { display: block; }

.toolbar { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar input[type="search"], .toolbar select { width: auto; min-width: 12rem; flex: 1 1 12rem; max-width: 22rem; }

.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--teal-wash); }
.empty i { display: block; font-size: 1.8rem; color: var(--teal); margin-bottom: 0.6rem; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.1rem 1.2rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.pill { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.75rem; font-weight: 700; padding: 0.12rem 0.55rem; border-radius: 999px; background: var(--teal-soft); color: var(--teal-deep); text-transform: uppercase; letter-spacing: 0.03em; }
.pill.orange { background: var(--orange-soft); color: #8a560e; }
.pill.grey { background: #eef1f2; color: var(--muted); }
.pill.green { background: var(--success-soft); color: var(--success); }

.item-card { display: flex; flex-direction: column; overflow: hidden; padding: 0; transition: box-shadow 0.2s, transform 0.2s; }
.item-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.item-card .photo { aspect-ratio: 4 / 3; background: var(--teal-wash); display: grid; place-items: center; color: var(--teal); font-size: 2.2rem; overflow: hidden; cursor: pointer; border: none; padding: 0; width: 100%; }
.item-card .photo img { width: 100%; height: 100%; object-fit: cover; }
.item-card .body { padding: 0.9rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.4rem; flex: 1; }
.item-card h3 { margin: 0; font-size: 1.05rem; }
.item-card .meta { font-size: 0.85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.2rem 0.8rem; }
.item-card .desc { font-size: 0.93rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.item-card .foot { margin-top: auto; padding-top: 0.5rem; display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.item-card.closed { opacity: 0.6; }

.list { display: flex; flex-direction: column; gap: 0.7rem; }
.row-card { display: flex; gap: 0.9rem; align-items: flex-start; }
.row-card .ico { width: 42px; height: 42px; border-radius: 10px; background: var(--teal-soft); color: var(--teal-deep); display: grid; place-items: center; flex: none; font-size: 1.1rem; }
.row-card .main { flex: 1; min-width: 0; }
.row-card h3 { margin: 0 0 0.15rem; font-size: 1.02rem; }
.row-card .side { display: flex; gap: 0.3rem; align-items: center; flex: none; }

.news-post { padding: 1.3rem 1.4rem; }
.news-post h3 { font-size: 1.2rem; }
.news-post .meta { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.7rem; }

/* ---------- Discussion ---------- */
.topic-row { cursor: pointer; }
.topic-row:hover { border-color: var(--teal); }
.topic-row.pinned, .comment.pinned { border-left: 4px solid var(--orange); }
.topic-stats { text-align: right; color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.topic-stats strong { display: block; color: var(--teal-deep); font-size: 1.1rem; }
.topic-head { margin-bottom: 1rem; }
.byline { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; color: var(--muted); }
.byline strong { color: var(--ink); }
.comment { margin-top: 0.7rem; }
.comment .top { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.pinned-label { color: var(--orange-dark); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.reply-box { margin-top: 1.2rem; }

/* ---------- Events ---------- */
.calendar-frame { width: 100%; height: min(78vh, 900px); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }

/* ---------- Tools ---------- */
.tool-card { position: relative; display: flex; gap: 0.9rem; align-items: flex-start; text-decoration: none; color: inherit; }
.tool-card .tool-admin { position: absolute; top: 0.4rem; right: 0.4rem; display: flex; background: rgba(255, 255, 255, 0.92); border-radius: 8px; }
.tool-card.editable { padding-right: 4.8rem; }
.tool-card:hover { border-color: var(--teal); box-shadow: var(--shadow); }
.tool-card .ico { width: 48px; height: 48px; border-radius: 12px; background: var(--teal-deep); color: #fff; display: grid; place-items: center; font-size: 1.25rem; flex: none; }
.tool-card:nth-child(3n + 2) .ico { background: var(--teal); }
.tool-card:nth-child(3n) .ico { background: var(--orange); color: #3a2405; }
.tool-card h3 { margin: 0 0 0.2rem; }
.tool-card p { margin: 0; color: var(--muted); font-size: 0.92rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th { background: var(--teal-wash); color: var(--teal-deep); font-weight: 700; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
tr.disabled td { color: var(--muted); }
td .actions { display: flex; gap: 0.2rem; justify-content: flex-end; }

/* ---------- Modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 40, 48, 0.45); }
.modal { position: relative; background: #fff; border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; padding: 1.4rem 1.5rem; }
.modal.wide { max-width: 860px; }
.modal-close { position: absolute; top: 0.7rem; right: 0.7rem; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.6rem; }
.gallery figure { margin: 0; position: relative; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.gallery figure .icon-btn { position: absolute; top: 4px; right: 4px; background: rgba(255, 255, 255, 0.9); }
.photo-full { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 10px; background: #0a2830; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--teal-deep); color: #fff; padding: 0.7rem 1.2rem; border-radius: 999px; box-shadow: var(--shadow); z-index: 60; font-weight: 600; max-width: calc(100vw - 32px); }
.toast.error { background: var(--danger); }

@media (max-width: 640px) {
  html { font-size: 16px; }
  .brand img { width: 46px; }
  .brand-sub, .who { display: none; }
  .user-menu-button { padding: 0.3rem; }
  .user-menu-button .chevron { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .tab { padding: 0.65rem 0.7rem; }
  .row-card { flex-wrap: wrap; }
  .hide-sm { display: none; }
  .modal { padding: 1.2rem 1.1rem; }
}
