:root {
  --bg: #f3f8f8;
  --surface: #ffffff;
  --surface-soft: #e8f3f1;
  --primary: #1f4f5f;
  --accent: #2c7a7b;
  --text: #16333c;
  --muted: #375760;
  --border: #c6dde0;
  --focus: #0a5e8a;
  --danger-bg: #fff4d6;
  --danger-border: #d1a947;
  --danger-text: #4d3b0b;
  --max-width: 1080px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: linear-gradient(180deg, #f7fbfc 0%, #eef7f5 100%);
}

a {
  color: var(--primary);
}

a:hover,
a:focus {
  color: #123744;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

input[type="range"]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.crisis-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  background: var(--danger-bg);
  color: var(--danger-text);
  border-bottom: 2px solid var(--danger-border);
}

.crisis-banner .inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.9rem 1rem;
  font-weight: 600;
}

.site-header,
main,
.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem;
}

.site-header h1 {
  margin: 0.4rem 0 0.25rem;
  color: var(--primary);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.2;
}

.tagline {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 1.02rem;
}

.nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
}

.nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
}

.nav a {
  display: inline-block;
  padding: 0.45rem 0.65rem;
  text-decoration: none;
  border-radius: 7px;
  color: var(--primary);
  font-weight: 600;
}

.nav a[aria-current="page"],
.nav a:hover,
.nav a:focus-visible {
  background: var(--surface-soft);
}

main {
  padding-top: 1.2rem;
  padding-bottom: 2rem;
}

.section-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem;
  margin-bottom: 1rem;
}

.topic-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.topic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.topic-card h3 {
  margin-top: 0;
  margin-bottom: 0.45rem;
  font-size: 1.1rem;
}

.topic-card p {
  margin: 0;
  color: var(--muted);
}

.topic-card a {
  text-decoration: none;
}

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.card-icon svg {
  width: 1.15rem;
  height: 1.15rem;
}

h2,
h3 {
  color: var(--primary);
}

ul {
  padding-left: 1.2rem;
}

li {
  margin-bottom: 0.5rem;
}

.resource-list li {
  margin-bottom: 0.75rem;
}

.disclaimer {
  background: #edf6ff;
  border: 1px solid #c6def4;
  border-radius: 10px;
  padding: 0.8rem 0.9rem;
  color: #244a63;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  padding-bottom: 2rem;
  color: var(--muted);
  font-size: 0.96rem;
}

@media (max-width: 680px) {
  .crisis-banner .inner {
    font-size: 0.86rem;
    line-height: 1.35;
    padding: 0.6rem 0.75rem;
  }

  .nav ul {
    gap: 0.3rem;
  }

  .nav a {
    padding: 0.4rem 0.55rem;
    font-size: 0.93rem;
  }
}

/* Thought Record Tool */
.tr-form label {
  display: block;
  font-weight: 600;
  margin-top: 0.9rem;
  margin-bottom: 0.3rem;
  color: var(--primary);
}

.tr-form textarea,
.tr-form input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  min-height: 70px;
}

.tr-form input[type="text"] {
  min-height: auto;
}

.tr-form input[type="range"] {
  width: 100%;
}

.tr-form .range-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tr-form .range-value {
  font-weight: 700;
  color: var(--accent);
  min-width: 2.5rem;
  text-align: right;
}

.tr-form button,
.tr-actions button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
}

.tr-form button:hover,
.tr-actions button:hover {
  background: #215f60;
}

.tr-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.tr-entry {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem;
  margin-bottom: 0.75rem;
  background: var(--surface-soft);
}

.tr-entry-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
  gap: 0.5rem;
}

.tr-entry-detail {
  margin-top: 0.6rem;
  display: none;
}

.tr-entry-detail.open {
  display: block;
}

.tr-entry-detail dt {
  font-weight: 600;
  color: var(--primary);
  margin-top: 0.5rem;
}

.tr-entry-detail dd {
  margin: 0.15rem 0 0;
}

.tr-delete {
  background: transparent;
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
}

.tr-clear-all {
  background: transparent !important;
  border: 1px solid var(--muted);
  color: var(--muted) !important;
}

.tr-process {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.tr-process:hover {
  background: var(--surface-soft);
}

.wt-status {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  margin-left: 0.5rem;
}

.wt-mini-form {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
}

.wt-mini-form label {
  display: block;
  font-weight: 600;
  margin-top: 0.6rem;
  margin-bottom: 0.25rem;
  color: var(--primary);
  font-size: 0.95rem;
}

.wt-mini-form select,
.wt-mini-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
}

.tr-empty {
  color: var(--muted);
  font-style: italic;
}

/* Grounding & Breathing tool */
.breathing-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem 1rem;
}

.breathing-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #eaf6f5, var(--accent));
  border: 3px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 4s ease-in-out;
  transform: scale(0.7);
}

.breathing-circle.grow {
  transform: scale(1.35);
  transition: transform 4s ease-in-out;
}

.breathing-circle.shrink {
  transform: scale(0.7);
  transition: transform 4s ease-in-out;
}

.breathing-circle.hold-in {
  transform: scale(1.35);
  transition: none;
}

.breathing-circle.hold-out {
  transform: scale(0.7);
  transition: none;
}

.breathing-label {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--primary);
  min-height: 1.8rem;
  text-align: center;
}

.breathing-sub {
  font-size: 0.95rem;
  color: var(--muted);
  text-align: center;
  min-height: 1.4rem;
}

.breathing-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
}

.breathing-controls button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  cursor: pointer;
}

.breathing-controls button:hover {
  background: var(--primary);
}

.breathing-controls select {
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 1rem;
}

.breathing-cycles {
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

.grounding-step {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--surface-soft);
}

.grounding-step h3 {
  margin-top: 0;
  color: var(--primary);
}

.grounding-step textarea {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
}

/* Skip to main content link (accessibility) */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--focus);
  color: #fff;
  padding: 0.7rem 1.2rem;
  border-radius: 0 0 8px 0;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}

/* Mood Tracker chart styles */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mt-chart-wrap {
  overflow-x: auto;
  padding: 1rem 0.5rem 0.5rem 0.5rem;
}

.mt-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 160px;
  min-width: 100%;
}

.mt-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 22px;
}

.mt-bar {
  width: 18px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.mt-bar-label {
  font-size: 0.65rem;
  color: #666;
  margin-top: 4px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  max-height: 60px;
}

.mt-chart-empty {
  color: #666;
  font-style: italic;
}
