/* ----- Theme variables ----- */
:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --text: #1f2328;
  --muted: #57606a;
  --hint: #6e7781;
  --border: #d8dee4;
  --rule: #5b6470;
  --card-bg: #ffffff;
  --card-border: #6e7781;
  --btn-bg: #ffffff;
  --btn-hover: #f0f3f6;
  --btn-active-bg: #24292f;
  --btn-active-text: #ffffff;
  --input-bg: #ffffff;
  --input-border: #b3bcc4;
  --submit-bg: #24292f;
  --submit-hover: #3a4047;
  --submit-text: #ffffff;
  --link: #0969da;
  --link-visited: #6e3eb3;
  --link-active: #0550ae;
  --asterisk: #cf222e;
  --marker: #8a939d;
  --shadow: 0 1px 3px rgba(31, 35, 40, 0.08), 0 1px 2px rgba(31, 35, 40, 0.04);
  --focus-ring: #0969da;
  --chip-bg: rgba(9, 105, 218, 0.08);
  --chip-bg-hover: rgba(9, 105, 218, 0.18);
  --chip-border: rgba(9, 105, 218, 0.35);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16181d;
  --text: #d8dde3;
  --muted: #8d96a0;
  --hint: #8d96a0;
  --border: #2c3038;
  --rule: #6b737d;
  --card-bg: #20242a;
  --card-border: #7d858f;
  --btn-bg: #20242a;
  --btn-hover: #2c3138;
  --btn-active-bg: #e6e6e6;
  --btn-active-text: #16181d;
  --input-bg: #20242a;
  --input-border: #3d434b;
  --submit-bg: #e6e6e6;
  --submit-hover: #ffffff;
  --submit-text: #16181d;
  --link: #7eb6ff;
  --link-visited: #b89bdc;
  --link-active: #b8d6ff;
  --asterisk: #ff7070;
  --marker: #8d96a0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --focus-ring: #7eb6ff;
  --chip-bg: rgba(126, 182, 255, 0.14);
  --chip-bg-hover: rgba(126, 182, 255, 0.28);
  --chip-border: rgba(126, 182, 255, 0.45);
}
html, body { background: var(--bg); }
body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  max-width: 800px;
  margin: 2em auto;
  padding: 0 1em;
  line-height: 1.55;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--link); transition: color 0.1s ease; }
a:visited { color: var(--link-visited); }
a:active  { color: var(--link-active); }
.link-button, .link-button:visited, .link-button:active { color: var(--submit-text); }
.talk .title a:visited, .past-talk .title a:visited { color: var(--link-visited); }
.talk .title a:active,  .past-talk .title a:active  { color: var(--link-active); }
h1 { border-bottom: 2px solid var(--rule); padding-bottom: 0.3em; }
.page-header {
  display: flex;
  align-items: center;
  gap: 1em;
  margin-top: 0;
}
.page-header h1 {
  margin: 0;
  border-bottom: none;
  padding-bottom: 0;
  flex: 1;
  font-size: 2em;
}
.page-header h1 a { color: inherit; text-decoration: none; }
.page-header h1 a:hover { color: var(--link); }
.page-header { border-bottom: 2px solid var(--rule); padding-bottom: 0.5em; }
.logo-link {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}
.logo-link:hover { opacity: 0.75; }
.logo-link:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; border-radius: 2px; }
.logo { height: 64px; width: auto; display: block; }
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark  { display: block; }
@media (max-width: 600px) {
  .page-header { gap: 0.6em; }
  .logo { height: 44px; }
}
h2 { margin-top: 1.5em; color: var(--text); }
nav.main-nav { margin: 1.5em 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5em; }
nav.main-nav a {
  padding: 0.5em 1em;
  background: var(--btn-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 1em;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
nav.main-nav a:hover {
  background: var(--btn-hover);
  border-color: var(--text);
  box-shadow: var(--shadow);
  text-decoration: none;
}
nav.main-nav a:active { transform: translateY(1px); box-shadow: none; }
nav.main-nav a:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
nav.main-nav a.active {
  background: var(--btn-active-bg);
  color: var(--btn-active-text);
  border-color: var(--btn-active-bg);
}
nav.main-nav a.active:hover { box-shadow: var(--shadow); }
#theme-toggle {
  position: fixed;
  top: 0.8em;
  right: 0.8em;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.25em 0.35em;
  background: var(--btn-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85em;
  cursor: pointer;
  line-height: 1;
}
#theme-toggle {
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
#theme-toggle:hover { background: var(--btn-hover); border-color: var(--text); box-shadow: var(--shadow); }
#theme-toggle:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
#theme-toggle .toggle-track {
  position: relative;
  width: 2.2em;
  height: 1.1em;
  background: var(--btn-hover);
  border-radius: 999px;
  border: 1px solid var(--border);
}
#theme-toggle .toggle-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: calc(1.1em - 4px);
  height: calc(1.1em - 4px);
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.2s ease;
}
[data-theme="dark"] #theme-toggle .toggle-thumb {
  transform: translateX(1.1em);
}
#theme-toggle .toggle-icon { font-size: 1em; }
.talk {
  margin: 1.5em 0;
  padding: 1em;
  border-left: 3px solid var(--card-border);
  background: var(--card-bg);
}
.talk .meta { color: var(--muted); font-size: 0.95em; margin-bottom: 0.5em; }
.talk .title { font-weight: bold; font-size: 1.1em; margin-bottom: 0.6em; }
.past-talk {
  margin: 0.6em 0;
  padding: 0.5em 0.9em;
  border-left: 3px solid var(--card-border);
  background: var(--card-bg);
}
.past-talk .meta { color: var(--muted); font-size: 0.9em; margin-bottom: 0.15em; }
.past-talk .title { font-weight: bold; font-size: 1.05em; }
.talk .title a, .past-talk .title a, a {
  color: var(--link);
  text-decoration: none;
}
.talk .title a:hover, .past-talk .title a:hover, a:hover {
  text-decoration: underline;
}
/* Talk detail view */
.detail-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6em;
  margin-bottom: 1em;
}
.detail-top-bar .back-link { margin-bottom: 0; }
.ics-button {
  padding: 0.45em 0.95em;
  font-size: 0.9em;
  font-family: inherit;
  font-weight: 500;
  background: var(--btn-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.ics-button:hover {
  background: var(--btn-hover);
  border-color: var(--text);
  box-shadow: var(--shadow);
}
.ics-button:active { transform: translateY(1px); box-shadow: none; }
.ics-button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.talk-detail .back-link {
  display: inline-block;
  margin-bottom: 1em;
  color: var(--link);
  text-decoration: none;
}
.talk-detail .back-link:hover { text-decoration: underline; }
.talk-detail .meta { color: var(--muted); font-size: 0.95em; margin-bottom: 0.3em; }
.talk-detail .title {
  font-size: 1.6em;
  font-weight: bold;
  margin: 0.2em 0 0.6em 0;
  line-height: 1.25;
}
.calendar-subscribe {
  font-size: 0.9em;
  color: var(--hint);
  margin: -0.4em 0 1em 0;
}
.calendar-subscribe a { color: var(--link); }
.abstract { margin-top: 1em; }
.abstract p { margin: 0 0 0.6em 0; }
.abstract p:first-of-type { display: inline; margin-left: 0.25em; }
.abstract p:last-of-type { margin-bottom: 0; }
.talk-detail .extras { margin-top: 1.5em; }
.talk-detail .extras h3 { margin-top: 1.2em; font-size: 1.1em; }
.talk-detail .extras ul { padding-left: 1.4em; }
.talk-detail .share-hint {
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
  font-size: 0.85em;
  color: var(--hint);
}
form { margin-top: 1em; }
label {
  display: block;
  margin-top: 1em;
  font-weight: bold;
}
input[type="text"], input[type="email"], select, textarea {
  width: 100%;
  padding: 0.55em 0.65em;
  font-family: inherit;
  font-size: 1em;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--input-border);
  border-radius: 5px;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]:focus, input[type="email"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px rgba(6, 69, 173, 0.18);
}
[data-theme="dark"] input[type="text"]:focus,
[data-theme="dark"] input[type="email"]:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  box-shadow: 0 0 0 3px rgba(126, 182, 255, 0.25);
}
textarea { min-height: 6em; resize: vertical; }
.rating { margin-top: 0.3em; }
.rating label { display: inline; font-weight: normal; margin-right: 1em; }
.hint { font-weight: normal; color: var(--hint); font-size: 0.9em; }

/* Tags / topic chips on talk cards */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35em;
  margin-top: 0.5em;
}
a.tag, button.tag {
  display: inline-block;
  padding: 0.2em 0.75em;
  font-size: 0.8em;
  font-family: inherit;
  font-weight: 500;
  background: var(--chip-bg);
  color: var(--link);
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
a.tag:hover, button.tag:hover {
  background: var(--chip-bg-hover);
  border-color: var(--link);
  text-decoration: none;
}
a.tag:active, button.tag:active { transform: translateY(1px); }
a.tag:focus-visible, button.tag:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Past Seminars search bar */
.past-controls { margin: 0.8em 0 1.2em 0; }
#past-search { width: 100%; max-width: 24em; }
#past-search-status { margin-top: 0.4em; min-height: 1.2em; }

/* Form result banner (success / error) */
#suggest-result { margin: 1em 0 0 0; }
#suggest-result:empty { display: none; }
.form-msg {
  padding: 0.9em 1em;
  border-radius: 6px;
  border-left: 4px solid var(--card-border);
  background: var(--card-bg);
}
.form-msg.success { border-left-color: #2e7d32; }
.form-msg.error   { border-left-color: #c62828; }
[data-theme="dark"] .form-msg.success { border-left-color: #66bb6a; }
[data-theme="dark"] .form-msg.error   { border-left-color: #ef5350; }
.form-msg p { margin: 0; }
.form-msg .submit-another {
  margin-top: 0.6em;
  background: none;
  border: none;
  color: var(--link);
  padding: 0;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}
label.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-weight: normal;
  margin-top: 1.2em;
  cursor: pointer;
}
label.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
  flex-shrink: 0;
}
label.required::after {
  content: " *";
  color: var(--asterisk);
  font-weight: bold;
}
button.submit {
  margin-top: 1.5em;
  padding: 0.7em 1.6em;
  font-size: 1em;
  font-weight: bold;
  background: var(--submit-bg);
  color: var(--submit-text);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
button.submit:hover {
  background: var(--submit-hover);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
button.submit:active { transform: translateY(0); box-shadow: none; }
button.submit:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
button.submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.link-button {
  display: inline-block;
  margin-top: 0.5em;
  padding: 0.7em 1.4em;
  background: var(--submit-bg);
  color: var(--submit-text);
  text-decoration: none;
  font-weight: bold;
  border-radius: 6px;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.link-button:hover { background: var(--submit-hover); box-shadow: var(--shadow); }
.link-button:active { transform: translateY(1px); box-shadow: none; }
.link-button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
footer { margin-top: 3em; font-size: 0.85em; color: var(--hint); border-top: 1px solid var(--border); padding-top: 1em; }

/* Prevent iOS zoom-on-focus by ensuring inputs render at >=16px */
input[type="text"], input[type="email"], select, textarea { font-size: 16px; }

/* Long words / emails shouldn't overflow on narrow screens */
body { overflow-wrap: break-word; word-wrap: break-word; }

@media (max-width: 600px) {
  body {
    margin: 1em auto;
    padding: 0 0.8em;
    font-size: 16px;
  }
  h1 { font-size: 1.5em; }
  h2 { font-size: 1.2em; }
  nav.main-nav a {
    display: block;
    width: 100%;
    padding: 0.7em 1em;
    text-align: left;
  }
  .talk, .past-talk {
    padding: 0.8em;
    margin: 1em 0;
  }
  .talk .meta, .past-talk .meta {
    font-size: 0.9em;
  }
  button.submit { width: 100%; }
}
