/* ============================================================
   My Plate & My Day
   Palette taken from a steel tiffin box on a school desk:
   chalk-green paper, deep leaf ink, and five plate colours that
   are categories, not verdicts. There is deliberately no red
   anywhere in this file.
   ============================================================ */

:root {
  --ink:       #17241D;
  --ink-soft:  #55665C;
  --paper:     #EDF2E9;
  --card:      #FFFFFF;
  --rule:      #D3DECE;
  --steel:     #DFE6DB;
  --deep:      #2E6B4F;

  --grain:     #E0A73C;
  --protein:   #C4633F;
  --veg:       #3E9B5F;
  --fruit:     #C24C7C;
  --dairy:     #4C8FC0;
  --sometimes: #F2A03D;
  --water:     #2D8FBF;
  --study:     #6B5CA5;

  --display: 'Baloo 2', 'Trebuchet MS', system-ui, sans-serif;
  --body: 'Karla', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow: 0 2px 0 var(--rule), 0 8px 24px -18px rgba(23, 36, 29, .5);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background:
    linear-gradient(transparent 31px, rgba(46, 107, 79, .06) 32px) 0 0 / 100% 32px,
    var(--paper);
  min-height: 100vh;
}

h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.2; margin: 0; }

.wrap { width: min(980px, 100% - 32px); margin-inline: auto; }
.wrap--narrow { width: min(560px, 100% - 32px); }

.screen { display: none; padding-block: 24px 56px; }
.screen.is-on { display: block; }

/* ---------- welcome ---------- */
.brand { text-align: center; padding-block: 20px 26px; }
.brand__mark { font-size: 52px; display: block; line-height: 1; }
.brand__title { font-size: clamp(30px, 7vw, 42px); font-weight: 800; letter-spacing: -.01em; margin-top: 6px; }
.brand__sub { color: var(--ink-soft); margin: 4px 0 0; }

.section-head { font-size: 22px; margin-bottom: 12px; }

.profile-list { display: grid; gap: 10px; margin-bottom: 16px; }

.profile-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; border: 2px solid var(--rule); border-radius: var(--r-md);
  background: var(--card); font: inherit; color: inherit; cursor: pointer; text-align: left;
}
.profile-btn:hover { border-color: var(--deep); }
.profile-btn small { display: block; color: var(--ink-soft); font-size: 14px; }

.avatar {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%;
  background: var(--deep); color: #fff; font-family: var(--display); font-weight: 700;
  display: grid; place-items: center; font-size: 20px;
}

.fineprint { font-size: 14px; color: var(--ink-soft); text-align: center; margin-top: 22px; }

/* ---------- ID card / setup ---------- */
.card {
  background: var(--card); border: 2px solid var(--rule); border-radius: var(--r-lg);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card__title { font-size: 19px; margin-bottom: 8px; }
.card__note { font-size: 14px; color: var(--ink-soft); margin: 0 0 12px; }

.idcard { position: relative; padding-top: 44px; overflow: hidden; }
.idcard__strip {
  position: absolute; inset: 0 0 auto 0; height: 30px; background: var(--deep); color: #fff;
  font-family: var(--display); font-size: 13px; letter-spacing: .18em; display: grid; place-items: center;
}

.field { display: block; margin-bottom: 14px; }
.field__label { display: block; font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.field__label em { font-weight: 400; color: var(--ink-soft); font-style: normal; }
.field__hint { display: block; font-size: 13px; color: var(--ink-soft); margin-top: 4px; }

input[type=text], input[type=number], input[type=month], input[type=password],
input[type=search], select {
  width: 100%; padding: 11px 12px; font: inherit; color: inherit;
  background: #fff; border: 2px solid var(--rule); border-radius: var(--r-sm);
}
input:focus-visible, select:focus-visible, button:focus-visible, .tab:focus-visible {
  outline: 3px solid var(--deep); outline-offset: 2px;
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row--tight { align-items: end; grid-template-columns: 1fr auto; }

.measure-note {
  background: var(--paper); border: 2px dashed var(--rule); border-radius: var(--r-md);
  padding: 12px 14px; font-size: 14.5px; margin-bottom: 16px;
}
.measure-note strong { font-family: var(--display); }
.measure-note ol { margin: 6px 0; padding-left: 20px; }
.measure-note p { margin: 6px 0 0; color: var(--ink-soft); }

/* ---------- buttons ---------- */
.btn {
  font: 600 16px var(--body); padding: 11px 18px; border-radius: var(--r-sm);
  border: 2px solid var(--deep); background: #fff; color: var(--deep); cursor: pointer;
}
.btn:hover { background: #F1F7F2; }
.btn--primary { background: var(--deep); color: #fff; }
.btn--primary:hover { background: #245B41; }
.btn--ghost { border-color: var(--rule); color: var(--ink); }
.btn--block { width: 100%; display: block; margin-top: 8px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; }

.linkbtn {
  background: none; border: 0; font: 600 15px var(--body); color: var(--deep);
  text-decoration: underline; cursor: pointer; padding: 8px 0;
}
.linkbtn--back { display: block; margin-bottom: 8px; }

.round {
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--rule);
  background: #fff; font: 700 20px var(--body); color: var(--ink); cursor: pointer;
}
.round:hover { border-color: var(--deep); }

/* ---------- topbar & tabs ---------- */
.topbar { background: var(--deep); color: #fff; padding: 12px 0; }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.who { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: #fff; cursor: pointer; font: inherit; text-align: left; }
.who__avatar {
  width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.18);
  display: grid; place-items: center; font-family: var(--display); font-size: 19px; font-weight: 700;
}
.who__name { display: block; font-family: var(--display); font-size: 19px; font-weight: 700; }
.who__meta { display: block; font-size: 13px; opacity: .85; }
.streak { background: rgba(255,255,255,.16); border-radius: 999px; padding: 6px 14px; font-size: 15px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; font: 600 15px var(--body); padding: 9px 15px; border-radius: 999px;
  border: 2px solid var(--rule); background: #fff; color: var(--ink-soft); cursor: pointer;
}
.tab.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }

.panel { display: none; }
.panel.is-on { display: block; }

.datestamp { font-family: var(--display); font-size: 15px; color: var(--ink-soft); margin: 6px 0 12px; }

/* ---------- the thali (signature) ---------- */
.plate-card { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: center; }
.plate-card__visual { position: relative; }
#thali { width: 220px; max-width: 100%; display: block; }
.wedge { transition: fill .35s ease, opacity .35s ease; }
.wedge-icon { font-size: 22px; transition: opacity .3s ease; }
.plate-card__title { font-size: 22px; }
.plate-card__msg { margin: 4px 0 12px; color: var(--ink-soft); }

.katori {
  position: absolute; right: -6px; bottom: 0; width: 70px; height: 70px; border-radius: 50%;
  background: var(--sometimes); color: #3A2708; display: grid; place-items: center;
  border: 4px solid var(--card); text-align: center; line-height: 1.1;
}
.katori__count { font-family: var(--display); font-size: 22px; font-weight: 800; display: block; }
.katori__label { font-size: 11px; font-weight: 700; }

.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.legend .dot { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 14px; }
.legend .done { margin-left: auto; font-size: 13px; color: var(--ink-soft); }

/* ---------- water ---------- */
.glasses { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.glass {
  width: 30px; height: 40px; border: 2px solid var(--water); border-top: 0;
  border-radius: 0 0 8px 8px; background: #fff; position: relative; overflow: hidden;
}
.glass::after {
  content: ''; position: absolute; inset: auto 0 0 0; height: 0; background: var(--water);
  transition: height .3s ease;
}
.glass.is-full::after { height: 100%; }
.counter { display: flex; align-items: center; gap: 14px; font-family: var(--display); font-size: 22px; }

/* ---------- study ---------- */
.study-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.toggle {
  display: flex; align-items: center; gap: 10px; padding: 13px 14px; border-radius: var(--r-md);
  border: 2px solid var(--rule); background: #fff; font: 600 15px var(--body); color: var(--ink); cursor: pointer;
}
.toggle__icon { font-size: 20px; }
.toggle.is-on { background: var(--study); border-color: var(--study); color: #fff; }
.stepper { border: 2px solid var(--rule); border-radius: var(--r-md); padding: 8px 12px; display: block; }
.stepper__label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.stepper__row { display: flex; align-items: center; gap: 12px; }
.stepper__row b { font-family: var(--display); font-size: 18px; min-width: 74px; text-align: center; }

/* ---------- food picker ---------- */
.search { margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  font: 600 14px var(--body); padding: 7px 13px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--rule); background: #fff; color: var(--ink-soft);
}
.chip.is-on { color: #fff; }

.food-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.food {
  border: 2px solid var(--rule); border-radius: var(--r-md); background: #fff; cursor: pointer;
  padding: 10px 4px 8px; text-align: center; font: 500 13px var(--body); color: var(--ink);
  display: grid; gap: 2px; justify-items: center; position: relative;
}
.food:hover { border-color: var(--ink-soft); }
.food__icon { font-size: 26px; line-height: 1; }
.food.is-on { border-width: 3px; }
.food.is-on::after {
  content: '✓'; position: absolute; top: 3px; right: 5px; font-weight: 700; font-size: 13px;
}

.chosen { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  border: 2px solid var(--rule); background: #fff; font-size: 14.5px; cursor: pointer;
}
.pill--static { cursor: default; }
.pill b { font-weight: 600; }
.pill .x { color: var(--ink-soft); font-weight: 700; }
.empty { color: var(--ink-soft); font-size: 15px; padding: 10px 0; }

.factline {
  margin-top: 10px; padding: 10px 12px; border-left: 4px solid var(--veg);
  background: var(--paper); border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: 15px;
}

/* ---------- week / charts ---------- */
canvas { width: 100%; display: block; }
.qlist { margin: 0; padding-left: 20px; }
.qlist li { margin-bottom: 6px; }

/* ---------- badges ---------- */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.badge {
  border: 2px solid var(--rule); border-radius: var(--r-md); padding: 14px 10px; text-align: center;
  background: var(--paper); opacity: .55;
}
.badge.is-on { opacity: 1; background: #fff; border-color: var(--deep); }
.badge__icon { font-size: 30px; display: block; filter: grayscale(1); }
.badge.is-on .badge__icon { filter: none; }
.badge__name { font-family: var(--display); font-weight: 700; font-size: 15px; display: block; margin-top: 4px; }
.badge__how { font-size: 12.5px; color: var(--ink-soft); display: block; margin-top: 2px; }

/* ---------- grow ---------- */
.grow-summary { font-family: var(--display); font-size: 17px; margin: 10px 0; }
.howto { margin-top: 12px; font-size: 15px; }
.howto summary { cursor: pointer; font-weight: 700; }

/* ---------- learn ---------- */
.sortbox { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.sortbox h3 { font-size: 16px; margin-bottom: 8px; }
.sortbox__col { background: var(--paper); border-radius: var(--r-md); padding: 12px; }
.learn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.learn-item { border-radius: var(--r-md); padding: 12px; color: #fff; }
.learn-item h3 { font-size: 16px; }
.learn-item p { margin: 4px 0 0; font-size: 14px; }

/* ---------- teacher ---------- */
.tablewrap { overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.table th { font-family: var(--display); font-size: 14px; }

.foot { display: flex; gap: 18px; justify-content: center; padding-top: 20px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  max-width: calc(100% - 32px); text-align: center; z-index: 50;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 620px) {
  .plate-card { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .plate-card__side { width: 100%; }
  .legend li { text-align: left; }
  .sortbox { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  body { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- print (weekly certificate / record) ---------- */
@media print {
  body { background: #fff; }
  .topbar, .tabs, .foot, .picker, .toast, .linkbtn, .btn, .round { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; }
  .panel { display: block !important; }
}
