:root {
  --seafoam: #a9bdcb;
  --aegean: #2387ad;
  --sage: #b8d3ae;
  --sand: #f3e9d4;
  --sun: #f3b441;
  --ochre: #d49432;
  --berry: #8f1537;
  --gold: #f3c13d;

  --bg: #eef5f7;
  --panel: #ffffff;
  --panel-soft: #fdfbf6;
  --ink: #183746;
  --text: #214958;
  --muted: #5f7480;
  --line: #cfe0e6;
  --line-strong: #bdd3dc;
  --success: #3c9a6a;
  --warn: #b8741a;
  --danger: #cb4b3f;
  --accent: var(--aegean);
  --accent-strong: #146b8b;
  --shadow-soft: 0 14px 28px rgba(23, 53, 69, 0.1);
  --shadow-hero: 0 20px 42px rgba(23, 53, 69, 0.19);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 11px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  color: var(--text);
  font-family: "Avenir Next", "SF Pro Text", "Segoe UI", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at 8% -10%, rgba(169, 189, 203, 0.65), transparent 36%),
    radial-gradient(circle at 92% 2%, rgba(243, 180, 65, 0.44), transparent 28%),
    radial-gradient(circle at 50% 112%, rgba(184, 211, 174, 0.4), transparent 44%),
    linear-gradient(180deg, #f8fcfd 0%, var(--bg) 100%);
}

.shell {
  width: min(1060px, calc(100% - 1.05rem));
  margin: 0.78rem auto calc(1.2rem + env(safe-area-inset-bottom));
  display: grid;
  gap: 0.86rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.35rem;
  letter-spacing: -0.015em;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 2px 14px rgba(17, 34, 44, 0.38);
}

h2 {
  margin-bottom: 0.52rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

h3 {
  margin-bottom: 0.2rem;
}

.kicker {
  margin: 0 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

.subtle {
  color: var(--muted);
  font-size: 0.9rem;
}

.hero-banner {
  position: relative;
  isolation: isolate;
  height: clamp(190px, 28vw, 285px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-hero);
  border: 1px solid rgba(24, 55, 70, 0.2);
}

.hero-banner.compact {
  height: clamp(170px, 22vw, 220px);
}

.hero-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1rem 1.05rem;
  background:
    radial-gradient(circle at 86% 14%, rgba(243, 193, 61, 0.32), transparent 36%),
    linear-gradient(
      180deg,
      rgba(24, 55, 70, 0.08) 0%,
      rgba(24, 55, 70, 0.44) 44%,
      rgba(24, 55, 70, 0.78) 100%
    );
}

.hero-overlay .subtle {
  color: rgba(250, 253, 255, 0.88);
  max-width: 64ch;
  margin-bottom: 0;
}

.segmented-nav {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.3rem;
  padding: 0.26rem;
  border-radius: 13px;
  background: linear-gradient(
    145deg,
    rgba(169, 189, 203, 0.38),
    rgba(243, 233, 212, 0.6)
  );
  border: 1px solid rgba(24, 55, 70, 0.16);
  backdrop-filter: blur(7px);
}

.segmented-link {
  text-decoration: none;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: #3d5d6a;
  padding: 0.53rem 0.68rem;
  border-radius: 10px;
  transition: background-color 120ms ease, color 120ms ease;
}

.segmented-link.active {
  color: #133847;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px #cfdde4, 0 8px 14px rgba(20, 50, 64, 0.08);
}

.nav-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.58rem;
  align-items: center;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 0.44rem;
  font-size: 0.86rem;
  color: #3c5967;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid #d5e1e7;
  border-radius: 11px;
  padding: 0.38rem 0.5rem;
}

.lang-switch select {
  min-width: 90px;
  padding: 0.32rem 0.46rem;
  border-radius: 9px;
}

.panel {
  background:
    linear-gradient(
      156deg,
      rgba(255, 255, 255, 0.98) 0%,
      rgba(243, 233, 212, 0.38) 58%,
      rgba(169, 189, 203, 0.24) 100%
    );
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.95rem;
  box-shadow: var(--shadow-soft);
}

.settings-shell {
  gap: 0.95rem;
}

.settings-panel {
  padding: 1.05rem;
}

.settings-panel h2 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.settings-panel h2::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--aegean), var(--sun));
  box-shadow: 0 0 0 2px rgba(35, 135, 173, 0.17);
}

.settings-block {
  margin-top: 0.72rem;
  padding: 0.72rem;
  border-radius: 12px;
  border: 1px solid #d5e2e8;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.96), rgba(238, 247, 251, 0.82));
}

.settings-about .subtle {
  margin-bottom: 0.3rem;
}

.sources-panel .source-list {
  columns: 2;
  column-gap: 1.3rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.66rem;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 110px auto;
  gap: 0.58rem;
}

.full {
  grid-column: span 2;
}

label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.89rem;
  color: #4c6773;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.61rem;
}

input::placeholder {
  color: #9aaeb8;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(31, 136, 171, 0.3);
  outline-offset: 2px;
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 0.56rem 0.95rem;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

.button:active {
  transform: translateY(1px);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button.primary {
  color: #ffffff;
  font-weight: 600;
  background: linear-gradient(140deg, var(--aegean), var(--accent-strong) 56%, var(--berry));
  box-shadow: 0 10px 18px rgba(26, 77, 102, 0.24);
}

.button.secondary {
  color: #2b4e60;
  background: linear-gradient(145deg, #fffaf1, #f5ecd7);
  border: 1px solid #e2d1b0;
}

.button.ghost {
  color: #415f70;
  background: #f7fbfd;
  border: 1px dashed #aec8d5;
}

.button.danger {
  color: #a3352a;
  background: #ffeae7;
  border: 1px solid #f5cec9;
  border-radius: 9px;
  padding: 0.34rem 0.56rem;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.62rem;
}

.rule-card {
  border-radius: 12px;
  padding: 0.66rem;
  border: 1px solid #cddde3;
  background:
    radial-gradient(circle at 88% -22%, rgba(243, 180, 65, 0.28), transparent 42%),
    radial-gradient(circle at 10% 0%, rgba(169, 189, 203, 0.24), transparent 30%),
    #ffffff;
}

.rule-card.ok {
  border-color: rgba(60, 154, 106, 0.52);
  background:
    radial-gradient(circle at 95% -10%, rgba(110, 175, 109, 0.24), transparent 40%),
    #ffffff;
}

.rule-card.warn {
  border-color: rgba(184, 116, 26, 0.48);
  background:
    radial-gradient(circle at 95% -10%, rgba(243, 180, 65, 0.28), transparent 42%),
    #fffdf8;
}

.rule-card.over {
  border-color: rgba(203, 75, 63, 0.54);
  background:
    radial-gradient(circle at 95% -10%, rgba(203, 75, 63, 0.2), transparent 44%),
    #fffcfb;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.14rem 0.48rem;
  font-size: 0.74rem;
  color: #355566;
  background: rgba(168, 187, 200, 0.27);
  border: 1px solid #d3e0e6;
}

.meter {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e5edf0;
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--sage), #4ea576);
}

.desktop-table {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.51rem 0.45rem;
  border-bottom: 1px solid #e4ecef;
}

th {
  color: #65818d;
  font-size: 0.84rem;
  font-weight: 600;
}

.mobile-cards {
  display: none;
}

.entry-card {
  border-radius: 12px;
  border: 1px solid #dce8ec;
  background: #ffffff;
  padding: 0.64rem;
}

.row-between {
  display: flex;
  justify-content: space-between;
  gap: 0.52rem;
  margin-bottom: 0.27rem;
}

.stack-list {
  margin-top: 0.66rem;
  display: grid;
  gap: 0.56rem;
}

.list-item {
  border-radius: 12px;
  border: 1px solid #ccdde4;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.98), rgba(239, 247, 250, 0.9));
  padding: 0.64rem;
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.locked-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.11rem 0.45rem;
  font-size: 0.73rem;
  color: #355d6f;
  background: rgba(168, 187, 200, 0.25);
  border: 1px solid #cad8e0;
}

.rule-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(252px, 1fr));
  gap: 0.62rem;
}

.rule-edit-card {
  border-radius: 11px;
  border: 1px dashed #c8d7de;
  background:
    linear-gradient(180deg, rgba(168, 187, 200, 0.11), rgba(255, 255, 255, 0.88));
  padding: 0.62rem;
}

.row-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.52rem;
  margin-top: 0.8rem;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #385364;
}

.switch-row input {
  width: 16px;
  height: 16px;
}

.module-box {
  margin-top: 0.72rem;
  padding-top: 0.72rem;
  border-top: 1px solid #e0e8ec;
}

.module-box.hidden {
  display: none;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  border-radius: 999px;
  border: 1px solid #ccdbe2;
  color: #355364;
  background: #edf4f7;
  font-size: 0.8rem;
  padding: 0.14rem 0.43rem;
}

.chip button {
  border: 0;
  background: transparent;
  color: #4e6a79;
  border-radius: 7px;
  padding: 0 0.2rem;
  cursor: pointer;
}

.med-times {
  margin-top: 0.34rem;
}

.time-btn-wrap {
  align-self: end;
}

.source-list {
  margin: 0;
  padding-left: 1.08rem;
}

.source-list a {
  color: #176f95;
}

.about-callout {
  margin: 0.7rem 0 0;
  padding: 0.68rem 0.8rem;
  border-radius: 12px;
  color: #2f4b5a;
  background:
    linear-gradient(
      145deg,
      rgba(184, 211, 174, 0.44),
      rgba(243, 193, 61, 0.3)
    );
  border: 1px solid rgba(143, 21, 55, 0.16);
}

.faq-list {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.55rem;
}

.faq-item {
  border-radius: 12px;
  border: 1px solid #d6e3e9;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.96), rgba(240, 248, 251, 0.84));
  padding: 0.55rem 0.65rem;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  color: #26495a;
}

.faq-item p {
  margin: 0.55rem 0 0.45rem;
  color: #446271;
}

.faq-item a {
  color: #196f95;
  font-size: 0.9rem;
}

.junk-guide-panel {
  border-color: #d6e3c6;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.98), rgba(184, 211, 174, 0.2));
}

.tips-list {
  margin: 0.55rem 0 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.34rem;
  color: #335468;
}

.security-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(16, 34, 45, 0.72);
  backdrop-filter: blur(6px);
}

.security-card {
  width: min(460px, 100%);
  border-radius: 16px;
  border: 1px solid rgba(207, 224, 230, 0.9);
  padding: 1rem;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.98), rgba(243, 233, 212, 0.65));
  box-shadow: 0 18px 36px rgba(8, 23, 32, 0.3);
}

.security-card h2 {
  margin-bottom: 0.4rem;
}

.security-form {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.55rem;
}

.security-error {
  margin: 0;
  min-height: 1.15rem;
  color: var(--danger);
}

.day-chip {
  cursor: pointer;
}

.day-chip.active {
  background: linear-gradient(145deg, rgba(31, 136, 171, 0.2), rgba(175, 201, 174, 0.28));
  border-color: #94b7c4;
}

.routine-day-palette {
  margin-top: 0.28rem;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 0.4rem;
}

@media (max-width: 860px) {
  .hero-banner {
    height: 220px;
  }

  .hero-banner.compact {
    height: 185px;
  }

  .hero-overlay {
    padding: 0.92rem;
  }
}

@media (max-width: 740px) {
  .shell {
    width: calc(100% - 0.72rem);
    margin-top: 0.58rem;
  }

  .hero-banner,
  .panel {
    border-radius: 14px;
  }

  .hero-banner {
    height: 194px;
  }

  .hero-banner.compact {
    height: 170px;
  }

  .hero-overlay {
    padding: 0.78rem;
  }

  .hero-overlay .subtle {
    font-size: 0.85rem;
  }

  .sources-panel .source-list {
    columns: 1;
  }

  .form-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .nav-row {
    grid-template-columns: 1fr;
  }

  .lang-switch {
    justify-content: space-between;
  }

  .full {
    grid-column: auto;
  }

  .desktop-table {
    display: none;
  }

  .mobile-cards {
    display: grid;
    gap: 0.56rem;
  }

  .button {
    width: 100%;
  }

  .time-btn-wrap .button,
  .button.danger,
  .chip button {
    width: auto;
  }
}
