:root {
  --paper: #f4f1e8;
  --ink: #101820;
  --muted: #60717b;
  --card: rgba(255, 255, 255, 0.8);
  --card-strong: #ffffff;
  --line: rgba(16, 24, 32, 0.12);
  --green: #0f766e;
  --gold: #d08a1d;
  --red: #b93d45;
  --blue: #2b6cb0;
  --shadow: 0 22px 60px rgba(16, 24, 32, 0.14);
  --mono: "IBM Plex Mono", "Menlo", monospace;
  --sans: "Space Grotesk", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, rgba(15, 118, 110, 0.22), transparent 34rem),
    radial-gradient(circle at 92% 14%, rgba(208, 138, 29, 0.24), transparent 30rem),
    linear-gradient(135deg, #f7f4eb 0%, #e9efe9 100%);
  font-family: var(--sans);
}

body {
  min-height: 100vh;
}

.widget-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
}

.widget-hero {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin: 4px 0 14px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 4.4rem);
  letter-spacing: -0.055em;
  line-height: 0.92;
}

#widget-subtitle {
  max-width: 56ch;
  margin: 10px 0 0;
  color: var(--muted);
}

.app-link,
.widget-footer button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(16, 24, 32, 0.08);
  cursor: pointer;
  font: 700 0.84rem var(--sans);
  padding: 9px 13px;
  text-decoration: none;
  white-space: nowrap;
}

.status-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(16, 24, 32, 0.84);
  color: #fff;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  padding: 13px 15px;
}

.status-card.is-hidden {
  display: none;
}

.widget-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
}

.widget-card {
  position: relative;
  overflow: hidden;
  min-height: 154px;
  grid-column: span 4;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 17px;
}

.widget-card:first-child,
.widget-card:nth-child(2) {
  grid-column: span 6;
}

.widget-card::after {
  content: "";
  position: absolute;
  inset: auto -28px -42px auto;
  width: 130px;
  height: 130px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
}

.widget-card.tone-focus::after {
  background: rgba(43, 108, 176, 0.14);
}

.widget-card.tone-ok::after {
  background: rgba(15, 118, 110, 0.16);
}

.widget-card.tone-warn::after {
  background: rgba(185, 61, 69, 0.13);
}

.card-label {
  position: relative;
  z-index: 1;
  margin: 0 0 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card-value {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(1.45rem, 4.5vw, 2.35rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

.card-detail,
.card-footer {
  position: relative;
  z-index: 1;
  color: var(--muted);
  line-height: 1.42;
}

.card-detail {
  margin: 12px 0 0;
}

.card-footer {
  margin: 9px 0 0;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.metric-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 13px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.58);
  padding: 8px;
}

.metric span {
  display: block;
  color: var(--muted);
  font: 500 0.68rem var(--mono);
  margin-bottom: 3px;
}

.metric strong {
  font-size: 0.94rem;
}

.espresso-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.espresso-list li,
.slot-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 7px 10px;
}


.slot-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.slot-pill[data-status="done"] {
  border-color: rgba(15, 118, 110, 0.28);
  background: rgba(15, 118, 110, 0.1);
}

.slot-pill[data-status="planned"] {
  border-color: rgba(43, 108, 176, 0.28);
  background: rgba(43, 108, 176, 0.1);
}

.slot-pill[data-status="rest"] {
  border-color: rgba(208, 138, 29, 0.26);
  background: rgba(208, 138, 29, 0.1);
}

.widget-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.trend-section {
  margin-top: 28px;
}

.trend-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin: 0 0 10px;
}

.trend-heading .eyebrow {
  margin-bottom: 4px;
}

.trend-heading h2 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.04em;
}

.trend-heading > span {
  color: var(--muted);
  font: 0.7rem var(--mono);
}

.trend-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.trend-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  padding: 12px;
  overflow: hidden;
}

.trend-card p {
  margin: 0 0 5px;
  color: var(--muted);
  font: 0.67rem var(--mono);
}

.trend-card strong {
  font-size: 1.05rem;
}

.trend-card small {
  color: var(--muted);
  font: 0.68rem var(--mono);
}

.trend-card svg {
  display: block;
  width: 100%;
  height: 54px;
  margin-top: 8px;
}

.trend-baseline { stroke: var(--line); stroke-width: 1; }
.trend-line { fill: none; stroke: var(--green); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.trend-card.tone-gold .trend-line { stroke: var(--gold); }
.trend-card.tone-blue .trend-line { stroke: var(--blue); }
.trend-card.tone-red .trend-line { stroke: var(--red); }

@media (max-width: 760px) {
  .widget-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .app-link {
    width: fit-content;
  }

  .widget-card,
  .widget-card:first-child,
  .widget-card:nth-child(2) {
    grid-column: 1 / -1;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trend-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .widget-shell {
    padding-left: 11px;
    padding-right: 11px;
  }

  .widget-card {
    border-radius: 20px;
    padding: 15px;
  }

  .trend-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}
