/* HerbiGuide web: colours and gradients from the Android app (res/values/strings.xml, gradient_bg_*.xml). */
:root {
  --white: #ffffff;
  --black: #000000;
  --text: #111111;
  --muted: #444444;
  --bar: #e6e6e6;
  --line: #c8c8c8;

  --crop: #00b050;    --crop-bg: #e4ffe4;    --crop-sel: #c8ffc8;
  --weed: #ff0000;    --weed-bg: #ffe4e4;    --weed-sel: #ffc8c8;
  --insect: #0000ff;  --insect-bg: #e4e4ff;  --insect-sel: #c8c8ff;
  --disease: #ffc000; --disease-bg: #ffe4b3; --disease-sel: #ffd83d;
  --insectdisease-bg: #e4ffff;
  --home-bg: #c8c8c8;

  --accent: var(--black);
  --accent-bg: var(--home-bg);
  --accent-sel: #bfbfbf;

  --radius: 4px;
  --shadow: 0 2px 10px rgba(0, 0, 0, .35);
  --font: Roboto, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

.theme-crop    { --accent: var(--crop);    --accent-bg: var(--crop-bg);    --accent-sel: var(--crop-sel); }
.theme-weed    { --accent: var(--weed);    --accent-bg: var(--weed-bg);    --accent-sel: var(--weed-sel); }
.theme-insect  { --accent: var(--insect);  --accent-bg: var(--insect-bg);  --accent-sel: var(--insect-sel); }
.theme-disease { --accent: var(--disease); --accent-bg: var(--disease-bg); --accent-sel: var(--disease-sel); }
.theme-home    { --accent: var(--black);   --accent-bg: var(--home-bg);    --accent-sel: #bfbfbf; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}
body { background: #efefef; overflow: hidden; }

/* ---------- Phone frame ----------
   The screen is always a fixed box with its own scrolling, so the app lays out the same inside the frame
   (360x640, like a 2012 Galaxy S III) and full-screen on a real phone. html.framed is set by js/phone.js. */
.phone { position: relative; }
.phone-top, .keys, .statusbar { display: none; }

.screen {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #000;
}

.app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #efefef;
  container: app / inline-size;
}
.view { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.view.fill { overflow: hidden; display: flex; flex-direction: column; }
.view:focus { outline: none; }

html.framed body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: radial-gradient(circle at 50% 35%, #fbfbfb, #d6d9dc 70%, #c4c8cc);
}
html.framed .phone {
  zoom: var(--zoom, 1);
  padding: 58px 16px 0;
  border-radius: 54px;
  background: linear-gradient(145deg, #3a3d42, #16181b 45%, #2b2e33);
  box-shadow:
    inset 0 0 0 2px #55595f,
    inset 0 0 0 5px #111,
    0 25px 50px rgba(0, 0, 0, .35),
    0 6px 14px rgba(0, 0, 0, .25);
}
html.framed .screen {
  width: 360px;
  height: 640px;
  outline: 2px solid #000;
  box-shadow: 0 0 0 5px #0b0c0d;
}
html.framed .phone-top {
  display: flex;
  position: absolute;
  top: 24px;
  left: 0;
  right: 0;
  justify-content: center;
  align-items: center;
}
.earpiece { width: 64px; height: 6px; border-radius: 3px; background: linear-gradient(#050505, #2a2a2a); box-shadow: inset 0 1px 2px #000; }
.camera { width: 11px; height: 11px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #3b4a66, #07090d 60%); box-shadow: 0 0 0 2px #1d1f22; position: absolute; left: calc(50% + 62px); }
.sensor { width: 6px; height: 6px; border-radius: 50%; background: #1f2124; position: absolute; left: calc(50% - 80px); }

/* Android 4.x status bar: black, Holo-blue icons and clock */
html.framed .statusbar {
  display: flex;
  flex: none;
  height: 25px;
  padding: 0 6px;
  align-items: center;
  justify-content: space-between;
  background: #000;
  color: #33b5e5;
  font: 400 15px/1 Roboto, "Segoe UI", Arial, sans-serif;
  user-select: none;
}
.status-right { display: flex; align-items: center; gap: 4px; }
.status-right time { margin-left: 3px; letter-spacing: .02em; }

/* Hardware keys: capacitive Menu and Back, physical oval Home */
html.framed .keys {
  display: flex;
  height: 86px;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
}
.key {
  border: 0;
  background: none;
  min-height: 0;
  padding: 10px 12px;
  color: #8e949b;
  border-radius: 10px;
}
.key:hover:not(:disabled) { background: none; color: #d8dde2; }
.key:active:not(:disabled) { background: rgba(255, 255, 255, .06); color: #fff; }
.key-home {
  width: 108px;
  height: 36px;
  padding: 0;
  border-radius: 18px;
  background: linear-gradient(#34373c, #1d1f23);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), inset 0 -1px 0 rgba(0, 0, 0, .6), 0 0 0 2px #0d0e10, 0 0 0 3px #4a4e54;
  display: grid;
  place-items: center;
}
.key-home span { width: 64px; height: 16px; border: 1.5px solid #6d7278; border-radius: 8px; }
.key-home:hover:not(:disabled) { background: linear-gradient(#3b3e44, #222428); }
.key-home:active:not(:disabled) { background: linear-gradient(#1b1d20, #2e3136); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .7), 0 0 0 2px #0d0e10, 0 0 0 3px #4a4e54; }

/* In the frame, the phone's keys replace the on-screen Back/Home buttons, and the Menu key holds the list options. */
/* Dialogs, the options menu and the document viewer cover the app but not the status bar. */
html.framed .modal-backdrop,
html.framed .options-backdrop,
html.framed .viewer { top: 25px; }

html.framed [data-soft],
html.framed .unframed-only { display: none !important; }
html:not(.framed) .framed-only { display: none !important; }

/* Options menu opened by the Menu key (Holo dark, rising from the bottom of the screen) */
.options-backdrop { position: absolute; inset: 0; z-index: 70; background: rgba(0, 0, 0, .25); display: flex; align-items: flex-end; }
.options-menu { list-style: none; margin: 0; padding: 0; width: 100%; background: #282828; border-top: 2px solid #33b5e5; box-shadow: 0 -4px 12px rgba(0, 0, 0, .5); }
.options-menu button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-bottom: 1px solid #3a3a3a;
  border-radius: 0;
  background: none;
  color: #f2f2f2;
  font-size: 1.05rem;
  padding: 0 16px;
  text-align: left;
}
.options-menu button:hover:not(:disabled) { background: #3a3a3a; }
.options-menu button:active:not(:disabled) { background: #33b5e5; }
.options-menu button:disabled { background: none; color: #777; }
.options-menu .radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #9a9a9a; display: grid; place-items: center; }
.options-menu .radio.on::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #33b5e5; }

button, input, select { font: inherit; }

button {
  cursor: pointer;
  border: 1px solid #a8a8a8;
  border-radius: var(--radius);
  background: linear-gradient(#f4f4f4, #d6d6d6);
  color: var(--text);
  padding: .45em .9em;
  min-height: 2.5em;
}
button:hover:not(:disabled) { background: linear-gradient(#ffffff, #dedede); }
button:active:not(:disabled) { background: linear-gradient(#d0d0d0, #e8e8e8); }
button:disabled { color: #a0a0a0; cursor: default; background: #e4e4e4; border-color: #cfcfcf; }
button.primary { font-weight: 600; }
:focus-visible { outline: 3px solid #2684ff; outline-offset: 1px; }

/* ---------- Action bar (Android custom action bar) ---------- */
.bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .4rem .6rem;
  background: var(--bar);
  border-bottom: 3px solid #a8a8a8;
}
.bar .thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #bbb;
  flex: none;
  background: #fff;
}
.bar .titles { flex: 1; min-width: 0; }
.bar h1 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.1;
  color: var(--accent);
}
.bar .instructions { margin: .15rem 0 0; font-style: italic; color: var(--muted); font-size: .95rem; }
.bar .actions { display: flex; gap: .4rem; flex: none; }
.bar .overflow { border: 0; background: none; min-height: 0; font-size: 1.6rem; line-height: 1; padding: .15em .3em; color: #444; font-weight: 700; }
.bar .overflow:hover { background: rgba(0, 0, 0, .08); }
.bar.home { padding: .8rem 1rem; }
.bar.home .logo { height: 64px; max-width: 70%; object-fit: contain; }
.bar.home .version { margin-left: auto; align-self: flex-start; color: var(--muted); font-size: 1.1rem; }

/* ---------- Home ---------- */
.menu { list-style: none; margin: .5rem; padding: 0; }
.menu a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .6rem .8rem;
  margin-bottom: 2px;
  color: inherit;
  text-decoration: none;
  background: linear-gradient(#ffffff, var(--home-bg));
}
.menu a:hover { background: linear-gradient(#ffffff, #dcdcdc); }
.menu img { width: 90px; height: 90px; object-fit: cover; border: 2px solid #fff; box-shadow: 0 0 0 1px #bbb; flex: none; }
.menu h2 { margin: 0; font-size: 1.8rem; color: var(--accent); }
.menu p { margin: .2rem 0 0; color: var(--muted); font-size: 1.05rem; }
.menu .chev { margin-left: auto; color: #777; font-size: 1.6rem; }

/* ---------- Lists ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .5rem .6rem;
  background: #f6f6f6;
  border-bottom: 1px solid var(--line);
}
.toolbar input[type=search] { flex: 1 1 14rem; min-width: 0; padding: .45em .6em; border: 1px solid #aaa; border-radius: var(--radius); }
.toolbar select { padding: .4em; border: 1px solid #aaa; border-radius: var(--radius); background: #fff; }

.list-layout { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.list-main { flex: 1; min-height: 0; position: relative; }
.rows-scroll { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; }

.selected {
  flex: none;
  max-height: 38%;
  overflow: auto;
  border-bottom: 3px solid #a8a8a8;
  background: linear-gradient(#ffffff, var(--accent-bg));
}
.selected-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .3rem .6rem;
}
.selected-head h2 { margin: 0; font-size: 1.25rem; font-style: italic; color: var(--accent); }
.selected ul { list-style: none; margin: 0; padding: 0 .6rem .5rem; }
.selected li { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; border-top: 1px solid rgba(0, 0, 0, .06); }
.selected li .what { flex: 1; min-width: 0; background: none; border: 0; text-align: left; padding: .2rem; min-height: 0; }
.selected li .what b { font-size: 1.05rem; }
.selected li .info { border: 0; background: none; min-height: 0; padding: .3rem .5rem; font-size: 1.15rem; color: #555; }
.selected li .info:hover { color: #000; background: rgba(255, 255, 255, .7); }
.selected .empty { padding: 0 .6rem .6rem; color: var(--muted); font-style: italic; margin: 0; }

.rows { list-style: none; margin: 0; padding: 0 1.8rem 0 0; }
.rows > li[hidden] { display: none; }
.row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#ffffff, var(--row-bg, var(--accent-bg)));
}
.row.is-selected { background: var(--row-sel, var(--accent-sel)); }
.row .pick {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 0;
  border-radius: 0;
  background: none;
  padding: .55rem .7rem;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.row .pick:hover:not(:disabled) { background: rgba(255, 255, 255, .5); }
.row .name1 { font-weight: 700; font-size: 1.2rem; }
.row .name2 { font-style: italic; color: var(--muted); font-size: .9rem; }
.row .stages { color: var(--text); font-size: .9rem; }
.row .check { width: 1.4rem; text-align: center; font-weight: 700; color: var(--accent); flex: none; }
.row .info {
  flex: none;
  border: 0;
  background: none;
  min-height: 0;
  padding: .5rem .8rem;
  font-size: 1.35rem;
  color: #555;
}
.row .info:hover { color: #000; background: rgba(255, 255, 255, .6); }
.row[data-type=I]  { --row-bg: var(--insect-bg);  --row-sel: var(--insect-sel); }
.row[data-type=FI] { --row-bg: var(--insectdisease-bg); --row-sel: #c8ffff; }
.row[data-type=F]  { --row-bg: var(--disease-bg); --row-sel: var(--disease-sel); }
.row[data-type=H]  { --row-bg: var(--weed-bg);    --row-sel: var(--weed-sel); }

.az {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1.7rem;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  padding: .2rem 0;
}
.az-inner { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: space-evenly; }
.az button {
  border: 0;
  background: none;
  min-height: 0;
  padding: 0;
  font-size: .68rem;
  line-height: 1;
  font-weight: 700;
  color: #666;
}
.az button:hover { color: #000; background: rgba(0, 0, 0, .08); }

.status { padding: .7rem; margin: 0; text-align: center; color: var(--muted); }
.rate-hidden { filter: blur(4px); user-select: none; -webkit-user-select: none; }
.error { padding: 1rem; margin: 1rem; background: #fff0f0; border: 1px solid #f99; border-radius: var(--radius); }

/* ---------- Solutions ---------- */
.summary { padding: .6rem .8rem; background: #fafafa; border-bottom: 1px solid var(--line); font-size: .95rem; }
.summary p { margin: .15rem 0; }
.summary button { background: none; border: 0; padding: 0; min-height: 0; text-decoration: underline dotted; }
.solutions { list-style: none; margin: 0; padding: 0; }
.solution {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#ffffff, var(--accent-bg));
}
.solution > .card {
  cursor: pointer;
  padding: .7rem .8rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: .35rem;
}
.solution > .card:hover { background: rgba(255, 255, 255, .6); }
.solution .names h3 { margin: 0; font-size: 1.25rem; }
.solution .names p { margin: 0; font-style: italic; color: var(--muted); }
.rates { border-collapse: collapse; font-size: .95rem; }
.rates th, .rates td { padding: .1rem .7rem .1rem 0; text-align: left; }
.rates th { font-weight: 600; }
.rates .unit { font-weight: 400; color: var(--muted); font-size: .85rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .1rem .8rem; margin: 0; font-size: .95rem; }
.facts dt { font-weight: 600; }
.facts dd { margin: 0; }
.comments { margin: 0; white-space: pre-line; font-size: .92rem; color: #222; line-height: 1.4; }
.warning { color: var(--weed); font-weight: 700; font-size: .9rem; letter-spacing: .02em; }
.nosolution { padding: 1.2rem; white-space: pre-line; line-height: 1.45; }

@container app (min-width: 900px) {
  .solution > .card { grid-template-columns: minmax(14rem, 1.1fr) auto 1.4fr; column-gap: 1.5rem; align-items: start; }
  .solution .comments, .solution .warning { grid-column: 1 / -1; }
}

/* ---------- Modals ---------- */
.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .6rem;
}
.modal {
  background: #fff;
  border: 1px solid #555;
  box-shadow: var(--shadow);
  width: min(560px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
}
.modal-head { display: flex; align-items: flex-start; gap: .6rem; padding: .6rem .7rem .3rem; }
.modal-head .titles { flex: 1; min-width: 0; }
.modal-head h2 { margin: 0; color: var(--accent); font-size: 1.45rem; line-height: 1.15; }
.modal-head p { margin: .1rem 0 0; color: var(--accent); font-style: italic; font-weight: 600; font-size: 1.15rem; }
.modal-body { overflow: auto; padding: 0 .7rem; }
.modal-foot { display: flex; gap: .4rem; padding: .6rem .7rem; }
.modal-foot button { flex: 1; }
.modal p.message { margin: 0 0 1rem; line-height: 1.45; }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist label {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .35rem .3rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#ffffff, var(--accent-bg));
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
}
.checklist input { width: 1.5rem; height: 1.5rem; accent-color: var(--accent); flex: none; }

.info-items { list-style: none; margin: 0 0 .7rem; padding: 0; }
.info-items button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .9rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: linear-gradient(#ffffff, var(--home-bg));
  text-align: left;
  padding: .5rem;
}
.info-items img { width: 64px; height: 64px; object-fit: cover; border: 2px solid #fff; box-shadow: 0 0 0 1px #bbb; flex: none; background: #fff; }
.info-items .label { flex: 1; min-width: 0; }
.info-items .label b { display: block; font-size: 1.3rem; }
.info-items .label small { color: var(--muted); }
.info-items .chev { color: #777; font-size: 1.4rem; }

/* ---------- Document viewer (HTM / PDF) ---------- */
.viewer {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: #000;
  display: flex;
  flex-direction: column;
}
.viewer-head { display: flex; align-items: center; gap: .6rem; padding: .4rem .6rem; background: #000; }
.viewer-head h2 { flex: 1; margin: 0; color: var(--accent); font-size: 1.2rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-head a { color: #ddd; font-size: .9rem; }
.viewer iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.theme-home .viewer-head h2 { color: #fff; }

/* ---------- Weed identification ---------- */
.weedid { padding: .5rem; display: grid; gap: .5rem; }
.panel { background: #fff; border: 1px solid var(--line); }
.panel > h2 { margin: 0; }
.panel > h2 button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: 0;
  background: linear-gradient(#ffffff, var(--home-bg));
  font-size: 1.15rem;
  font-style: italic;
  font-weight: 700;
  text-align: left;
}
.panel .caret { font-style: normal; color: #666; }
.panel-body { padding: .6rem; }
.shortlist { line-height: 1.8; }
.shortlist button { border: 0; background: none; padding: 0 .1rem; min-height: 0; color: #a00000; text-decoration: underline; text-underline-offset: 2px; }
.question { display: flex; align-items: center; gap: 1rem; min-height: 90px; }
.question img { width: 80px; height: 80px; object-fit: contain; flex: none; }
.question p { margin: 0; font-size: 1.35rem; font-weight: 600; }
.answer-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; margin-top: .6rem; }
.answer-buttons .on { font-weight: 800; box-shadow: inset 0 0 0 2px #333; }
.tabs { display: flex; gap: .3rem; }
.tabs button[aria-selected=true] { font-weight: 700; background: #fff; box-shadow: inset 0 -3px 0 #333; }

.features > li { list-style: none; border-bottom: 1px solid var(--line); }
.features { margin: 0; padding: 0; }
.features summary {
  cursor: pointer;
  padding: .5rem .6rem;
  background: linear-gradient(#ffffff, #e6e6e6);
  display: flex;
  gap: .6rem;
  align-items: baseline;
}
.features summary b { font-size: 1.05rem; }
.features summary span { color: #a00000; font-size: .9rem; }
.features .values { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 2px; padding: .3rem; background: #f4f4f4; }
.feature {
  display: flex;
  align-items: center;
  gap: .5rem;
  border: 1px solid #ddd;
  border-radius: 0;
  background: #fff;
  text-align: left;
  padding: .3rem .4rem;
  min-height: 3rem;
}
.feature img.state { width: 28px; height: 28px; flex: none; }
.feature img.icon { width: 44px; height: 44px; object-fit: contain; flex: none; }
.feature[data-value="2"] { background: #e6ffe6; }
.feature[data-value="0"] { background: #ffe8e8; }
.feature[data-value="0"] .title { text-decoration: line-through; color: #777; }
.size-input { display: flex; align-items: center; gap: .5rem; background: #fff; border: 1px solid #ddd; padding: .4rem .6rem; }
.size-input label { flex: 1; font-weight: 600; }
.size-input input { width: 6rem; padding: .3rem; border: 1px solid #aaa; border-radius: var(--radius); }

/* ---------- About ---------- */
.about { padding: 1rem 1.2rem; line-height: 1.5; }
.about dl { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; }
.about dt { font-weight: 600; }
.about dd { margin: 0; }

/* ---------- Small screens (the phone frame, or a real phone) ---------- */
@container app (max-width: 600px) {
  .bar .thumb { width: 48px; height: 48px; }
  .bar h1 { font-size: 1.35rem; }
  .bar .instructions { font-size: .82rem; }
  .bar.home .logo { height: 44px; }
  .menu img { width: 64px; height: 64px; }
  .menu h2 { font-size: 1.4rem; }
  .menu p { font-size: .92rem; }
  .row .name1 { font-size: 1.05rem; }
  .answer-buttons { grid-template-columns: repeat(3, 1fr); }
  .bar { gap: .5rem; padding: .35rem .45rem; }
  .bar .actions button { padding: .4em .7em; }
  .selected-head h2 { font-size: 1.1rem; }
}
