:root {
  --ink: #14352b;
  --ink-light: #2c4e43;
  --muted: #597368;
  --green: #185e49;
  --green-light: #e8f3ed;
  --green-hover: #114536;
  --accent-orange: #c86326;
  --accent-rose: #d63d54;
  --line: #dfe7e1;
  --line-light: #edf2ee;
  --paper: #f6faf7;
  --card-bg: #ffffff;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-subtle: 0 2px 8px -2px rgba(20, 53, 43, 0.05), 0 1px 3px rgba(0, 0, 0, 0.02);
  --shadow-card: 0 4px 20px -4px rgba(20, 53, 43, 0.07), 0 1px 3px rgba(0, 0, 0, 0.03);
  --shadow-elevated: 0 14px 34px -8px rgba(20, 53, 43, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.7 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }
a { color: var(--green); text-decoration: none; transition: color 0.15s; }
a:hover { text-decoration: underline; color: var(--green-hover); }
p { margin: 6px 0; }

/* Layout Shell */
.compost-page main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 32px 64px;
}

.site-header {
  padding: 4px 0 18px;
}

.compost-page .home-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin-bottom: 8px;
  color: var(--green);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.compost-page .home-link:hover { color: var(--green-hover); }
.compost-page .home-link:focus-visible { outline: 2px solid var(--green); outline-offset: 4px; border-radius: 3px; }

.compost-page h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 2px 0 0;
  color: var(--ink);
}

.compost-page h2, .compost-page h3 { margin: 0; font-weight: 700; color: var(--ink); }
.compost-page h3 { font-size: 18px; line-height: 1.5; }

.compost-page .eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--green);
  text-transform: uppercase;
}

.compost-page .help {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}

/* Card Panels */
.compost-page .panel {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin: 20px 0;
  box-shadow: var(--shadow-card);
  min-width: 0;
}

/* ========================================================================= */
/* 1. Hero Story Banner with Integrated Stepper                              */
/* ========================================================================= */
.compost-page .intro {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  background: linear-gradient(135deg, #103328 0%, #174c3d 50%, #133d31 100%);
  color: #f2f8ed;
  padding: 34px 40px 30px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-elevated);
}

.intro::after {
  content: '';
  position: absolute;
  width: 380px;
  height: 380px;
  border: 1px solid rgba(184, 214, 157, 0.14);
  border-radius: 50%;
  right: 5%;
  top: -60px;
  box-shadow: 0 0 0 45px rgba(199, 223, 182, 0.04), 0 0 0 90px rgba(199, 223, 182, 0.02);
  pointer-events: none;
}

.compost-page .intro .eyebrow {
  color: #a7d396;
  font-size: 11px;
  letter-spacing: 0.15em;
  font-weight: 700;
}

.compost-page .intro h2 {
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.45;
  letter-spacing: -0.01em;
  margin: 10px 0 12px;
  color: #ffffff;
}

.intro p {
  font-size: 13.5px;
  color: #d1e5d6;
  line-height: 1.8;
  max-width: 650px;
  position: relative;
  z-index: 1;
  margin-bottom: 22px;
}

.intro-mark {
  position: absolute;
  right: 8%;
  top: 36px;
  font-family: serif;
  font-size: 46px;
  font-weight: 700;
  line-height: 1.35;
  color: rgba(194, 219, 164, 0.8);
  transform: rotate(-6deg);
  pointer-events: none;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

/* Integrated Stepper in Hero */
.hero-stepper-wrap {
  position: relative;
  z-index: 1;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 16px 20px;
  margin-top: 10px;
}

.stepper-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #a7d396;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.journey {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 0;
  margin: 0;
}

.journey li {
  position: relative;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-top: 3px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  padding: 12px 14px;
  min-width: 0;
  transition: all 0.2s ease;
}

.journey li.recorded {
  border-top-color: #86efac;
  background: rgba(255, 255, 255, 0.14);
}

.journey .step-number {
  display: inline-flex;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #e2e8e2;
  width: 22px;
  height: 22px;
  justify-content: center;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  margin-right: 6px;
}

.journey .recorded .step-number {
  background: #22c55e;
  color: #0d2b1f;
  box-shadow: 0 2px 6px rgba(34, 197, 94, 0.4);
}

.journey b {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
}

.journey small {
  display: block;
  margin-top: 6px;
  color: #c7ded0;
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* ========================================================================= */
/* 2. Slim Integrated Batch Control Bar                                      */
/* ========================================================================= */
.batch-bar {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.batch-info {
  flex: 1;
  min-width: 280px;
}

.batch-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 2px 0;
}

.compost-page #lotname {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}

.compost-page .chartmeta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.nav {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.nav button {
  min-height: 38px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  background: #f7faf8;
  border: 1px solid #c8d8cd;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}

.nav button:hover {
  background: #eaf3ed;
  border-color: var(--green);
}

/* Compact Controls inside Batch Bar */
.batch-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.compact-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.compact-label select,
.compact-label input {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: white;
  border: 1px solid #cbd8cf;
  border-radius: 8px;
  padding: 8px 12px;
  transition: all 0.15s;
  min-height: 38px;
}

.compact-label select:focus,
.compact-label input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(24, 94, 73, 0.15);
}

.compact-label.lotselect select {
  font-weight: 700;
  color: var(--ink);
  max-width: 220px;
}

/* Status Notifications */
.connection, .warning {
  padding: 12px 16px;
  border-radius: 12px;
  background: #edf7ef;
  border-left: 4px solid var(--green);
  font-size: 13px;
  color: var(--ink);
  margin: 12px 0;
}

.connection.error, .warning {
  background: #fff8f0;
  border-left-color: #d97706;
  color: #8c5311;
}

/* ========================================================================= */
/* 3. 4 Great Highlights (KPI Cards) - Placed Upfront                        */
/* ========================================================================= */
.highlights {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.highlight {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #ffffff;
  min-width: 0;
  box-shadow: var(--shadow-subtle);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.highlight:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

/* Card 1: 最高到達温度 (Warm Rose) */
.highlight:nth-child(1) {
  background: linear-gradient(to bottom, #fffdfd, #ffffff);
  border-color: #ffd8dc;
  border-top: 3.5px solid #e11d48;
}
.highlight:nth-child(1) strong { color: #be123c; }

/* Card 2: 60℃以上の記録 (Safe Emerald) */
.highlight:nth-child(2) {
  background: linear-gradient(to bottom, #f7fdf9, #ffffff);
  border-color: #bbf7d0;
  border-top: 3.5px solid #059669;
}
.highlight:nth-child(2) strong { color: #047857; }

/* Card 3: 切り返しの記録 (Active Amber) */
.highlight:nth-child(3) {
  background: linear-gradient(to bottom, #fffdf8, #ffffff);
  border-color: #fde68a;
  border-top: 3.5px solid #d97706;
}
.highlight:nth-child(3) strong { color: #b45309; }

/* Card 4: 積算温度 (Solid Slate) */
.highlight:nth-child(4) {
  background: linear-gradient(to bottom, #fafbfb, #ffffff);
  border-color: #cbd5e1;
  border-top: 3.5px solid #475569;
}
.highlight:nth-child(4) strong { color: #1e293b; }

.highlight > span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  display: block;
}

.highlight strong {
  display: block;
  font-size: 38px;
  line-height: 1.35;
  font-weight: 900;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin: 4px 0 6px;
}

.highlight strong em {
  font-size: 14px;
  font-weight: 600;
  font-style: normal;
  letter-spacing: 0;
  margin-left: 4px;
  color: var(--muted);
  white-space: nowrap;
}

.highlight small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

/* ========================================================================= */
/* 4. Segmented Modern Tabs                                                  */
/* ========================================================================= */
.tabs {
  display: flex;
  background: #e9efe7;
  padding: 5px;
  border-radius: 14px;
  gap: 4px;
  margin: 20px 0 20px;
  border-bottom: none;
}

.compost-page .tabs button {
  flex: 1;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #556c62;
  font-size: 13.5px;
  font-weight: 600;
  padding: 12px 18px;
  box-shadow: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.compost-page .tabs button:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.5);
}

.compost-page .tabs button[aria-selected="true"] {
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(20, 53, 43, 0.08);
}

/* ========================================================================= */
/* 5. Chart Panel & Heat of Fermentation                                    */
/* ========================================================================= */
.compost-page .chart-panel {
  padding: 28px 30px;
}

.chart-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 12px;
}

.chart-tools label {
  width: 200px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.chart-tools select {
  width: 100%;
  margin-top: 4px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #cbd8cf;
  font: inherit;
  font-size: 13px;
}

.compost-page #chart {
  height: 560px;
  width: 100%;
  min-width: 0;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  padding: 12px 16px;
  background: #f7faf8;
  border-radius: 10px;
  border: 1px solid var(--line-light);
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.dot.ai { background: #709b99; }
.dot.confirmed { background: #006c61; }
.dot.turning { border: 2px solid #cf4c47; background: white; }
.zone {
  display: inline-block;
  width: 14px;
  height: 10px;
  background: #e2f1e6;
  border: 1px solid #b8deb6;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

/* Story Events Grid (Chart Footnotes) */
.story-events {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.story-event {
  font-size: 12px;
  min-width: 0;
  background: #f8faf8;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid var(--line-light);
}

.story-event b {
  display: block;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 6px;
}

.story-event small {
  display: block;
  color: var(--muted);
  line-height: 1.6;
}

/* ========================================================================= */
/* 6. Knowledge Callout (Compost Insights)                                   */
/* ========================================================================= */
.knowledge {
  padding: 26px 32px;
  background: linear-gradient(135deg, #fbfcf9 0%, #f4f8f3 100%);
  border: 1px solid #dce8dd;
  border-left: 5px solid var(--green);
  border-radius: var(--radius-md);
  margin: 24px 0 28px;
  box-shadow: var(--shadow-subtle);
}

.knowledge h3 {
  margin: 6px 0 10px !important;
  font-size: 19px;
  color: var(--ink);
}

.knowledge p {
  font-size: 14px;
  line-height: 1.9;
  color: #344f43;
}

.knowledge a {
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  padding: 6px 14px;
  background: white;
  border: 1px solid #c9d8cd;
  border-radius: 8px;
}

/* ========================================================================= */
/* 7. Data Table Panel (Tab 3)                                               */
/* ========================================================================= */
.tabletop {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin: 20px 0 16px;
}

.tabletop p {
  flex: 1;
  min-width: 200px;
}

.tabletop select {
  width: 240px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid #cbd8cf;
  font: inherit;
  font-size: 13px;
}

.tabletop button {
  padding: 10px 18px;
  background: var(--green);
  color: white;
  border: 1px solid var(--green);
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.tabletop button:hover {
  background: var(--green-hover);
}

.tablewrap {
  overflow: auto;
  max-height: 620px;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-subtle);
}

table {
  border-collapse: collapse;
  min-width: 1000px;
  width: 100%;
  font-size: 12px;
  background: white;
}

.compost-page th {
  position: sticky;
  top: 0;
  background: #edf3eb;
  color: var(--ink);
  font-weight: 700;
  padding: 12px 10px;
  border-bottom: 2px solid #ccdacf;
  z-index: 1;
}

.compost-page td {
  white-space: normal;
  min-width: 80px;
  max-width: 300px;
  overflow-wrap: anywhere;
  vertical-align: top;
  padding: 11px 10px;
  border-bottom: 1px solid #edf1ee;
}

.compost-page tr:hover td {
  background: #f7faf7;
}

.compost-page .temp {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.compost-page tr:focus {
  outline: 2px solid #bc7830;
  outline-offset: -2px;
  background: #fff8eb;
}

/* Process Timeline (Tab 2) */
.compost-page .process-events {
  margin-top: 24px;
  display: grid;
  gap: 20px;
}

.compost-page .process-event {
  border-left: 3px solid var(--green);
  padding: 6px 0 6px 20px;
  background: #f8faf8;
  border-radius: 0 12px 12px 0;
}

.process-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  border-bottom: 1px solid #e9edea;
  padding: 12px 0;
}

.process-row:last-child {
  border-bottom: none;
}

.process-field {
  font-size: 13px;
}

.process-field span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.process-field b {
  font-weight: 600;
  color: var(--ink);
}

.compost-page .section-heading {
  margin: 36px 0 16px;
}

.work-events {
  display: grid;
  gap: 0;
}

.work-event {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.work-event time {
  color: var(--muted);
  font-weight: 600;
}

/* Empty & Footer */
.empty {
  padding: 36px;
  background: #f5f8f5;
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.reading {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.8;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.summary > div {
  padding: 14px;
  background: #f8faf8;
  border-radius: 10px;
  border: 1px solid var(--line-light);
}

.summary b {
  font-size: 20px;
  color: var(--ink);
  display: block;
}

.compost-page footer {
  padding: 32px 0 24px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line-light);
  margin-top: 40px;
}

/* Public Mode Navigation Bar */
.compost-page[data-role="public"] {
  padding-left: 0;
}

.compost-page[data-role="public"] .workspace-nav {
  position: static;
  width: 100%;
  padding: 14px max(24px, calc((100vw - 1280px) / 2));
  background: #ffffff;
  border: 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.compost-page[data-role="public"] .workspace-brand {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.compost-page[data-role="public"] .workspace-links {
  display: flex;
}

.compost-page[data-role="public"] .workspace-links a {
  padding: 6px 18px;
  font-size: 12px;
  border-radius: 8px;
}

.compost-page[data-role="public"] #details th:nth-child(6),
.compost-page[data-role="public"] #details td:nth-child(6),
.compost-page[data-role="public"] [data-private-compost] {
  display: none;
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
  .compost-page main { padding: 18px 24px; }
  .batch-bar { flex-direction: column; align-items: stretch; gap: 16px; }
  .batch-controls { justify-content: flex-start; }
  .highlights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .highlight strong { font-size: 32px; }
  .journey { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .intro-mark { right: 5%; font-size: 38px; }
}

@media (max-width: 768px) {
  .compost-page main { padding: 12px 16px; }
  .compost-page .intro { padding: 24px 20px 22px; }
  .intro-mark { display: none; }
  .batch-bar { padding: 16px; }
  .batch-title-row { flex-wrap: wrap; gap: 10px; }
  .compost-page #lotname { font-size: 28px; }
  .batch-controls { flex-direction: column; align-items: stretch; gap: 10px; }
  .compact-label { flex-direction: column; align-items: flex-start; }
  .compact-label select,
  .compact-label input { width: 100%; max-width: none !important; }
  .tabs { gap: 2px; }
  .compost-page .tabs button { font-size: 12px; padding: 10px 6px; }
  .journey { grid-template-columns: 1fr; gap: 10px; }
  .highlights { grid-template-columns: 1fr; gap: 12px; }
  .chart-tools { flex-direction: column; align-items: flex-start; }
  .chart-tools label { width: 100%; }
  .compost-page #chart { height: 500px; }
  .story-events { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* Restore the detail-tab metrics removed during the layout redesign. */
.temperature-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin: 24px 0;
}
.temperature-stat { min-width: 0; padding: 16px 0; border-top: 2px solid #cbdcd1; }
.temperature-stat > span { display: block; font-size: 13px; color: var(--muted); }
.temperature-stat strong { display: block; margin: 6px 0; font-size: 30px; line-height: 1.4; color: var(--ink); }
.temperature-stat small { display: block; font-size: 12px; line-height: 1.7; color: var(--muted); overflow-wrap: anywhere; }
.batch-info, .batch-controls, .compact-label { min-width: 0; }
.compost-page #lotname { overflow-wrap: anywhere; }
@media (max-width: 768px) {
  .temperature-stats { grid-template-columns: 1fr; gap: 12px; }
  .temperature-stat { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 10px; }
  .temperature-stat strong { margin: 0; }
  .temperature-stat small { grid-column: 1 / -1; }
}
