/* logo lettering: Space Grotesk SemiBold (SIL OFL 1.1, css/SpaceGrotesk-OFL.txt), subset */
@font-face { font-family: 'MeteriaLogo'; src: url(logo-type.woff2) format('woff2'); font-display: block; }
/* Meteria app: light instrument look (same family as the landing) – light grey body, dark ink, red needle accent. */
:root {
  --body: #ecebe6; --panel: #f7f6f2; --ink: #23272b; --muted: #6b6f73; --line: #d6d4cd; --red: #d8432f; --green: #2f8f5b;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --tabs: calc(64px + env(safe-area-inset-bottom));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--body); color: var(--ink); }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { display: flex; flex-direction: column; height: 100%; max-width: 760px; margin: 0 auto; }

/* top bar */
.top {
  flex: none; display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  border-bottom: 1px solid var(--line); background: var(--body);
}
.top h1 { margin: 0; font-size: 1.25rem; letter-spacing: -.01em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { border: 0; background: none; font-size: 2rem; line-height: 1; padding: 0 8px 4px 0; color: var(--ink); }
.rec-pill { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; background: var(--red); color: #fff; font: 600 .82rem var(--mono); font-variant-numeric: tabular-nums; }
.rec-pill i { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: .2; } }

main { flex: 1; overflow-y: auto; padding: 16px 16px 24px; -webkit-overflow-scrolling: touch; }

/* bottom tabs with the record button in the middle */
.tabs {
  flex: none; display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center; height: var(--tabs); padding: 0 12px env(safe-area-inset-bottom);
  border-top: 1px solid var(--line); background: var(--panel);
}
.tabs [data-tab] { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: .72rem; font-weight: 600; letter-spacing: .02em; }
.tabs [data-tab] svg { width: 24px; height: 24px; }
.tabs [data-tab].on { color: var(--ink); }
.recbtn { position: fixed; z-index: 15; right: max(18px, calc(50vw - 380px + 18px)); bottom: calc(var(--tabs) + 16px); width: 62px; height: 62px; border-radius: 50%; border: 0; background: var(--panel); box-shadow: 0 0 0 1px var(--line), 0 4px 14px rgba(35, 39, 43, .2); display: flex; align-items: center; justify-content: center; }
.recbtn i { width: 24px; height: 24px; border-radius: 50%; background: var(--red); transition: border-radius .15s, width .15s, height .15s; }
.recording .recbtn i { width: 20px; height: 20px; border-radius: 4px; }

/* buttons */
.btn { border: 0; border-radius: 12px; padding: 12px 18px; background: var(--ink); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn.red { background: var(--red); }
.btn.danger { color: var(--red); box-shadow: inset 0 0 0 1.5px var(--red); }
.row { display: flex; gap: 10px; margin: 14px 0; }
.row .btn { flex: 1; }
.hint { color: var(--muted); font-size: .88rem; margin: 14px 0 0; }

.banner { background: var(--panel); border-radius: 16px; padding: 16px; margin-bottom: 14px; box-shadow: inset 0 0 0 1px var(--line); }
.banner p { margin: 0 0 12px; }

/* sensor cards */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { text-align: left; border: 0; border-radius: 16px; padding: 14px; min-height: 92px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; justify-content: space-between; }
.card:active { background: #efeee9; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; font-weight: 600; font-size: .95rem; line-height: 1.2; }
.card-top em { font: 600 .66rem var(--mono); font-style: normal; letter-spacing: .1em; color: var(--red); border: 1.5px solid currentColor; border-radius: 5px; padding: 2px 4px; }
.card-val { font: 600 1.05rem var(--mono); font-variant-numeric: tabular-nums; margin-top: 10px; }
.card.off { opacity: .55; }
.card.off .card-val { font: .85rem inherit; color: var(--muted); }

/* detail */
.widget { background: var(--panel); border-radius: 20px; padding: 10px 10px 4px; box-shadow: inset 0 0 0 1px var(--line); }
.widget:empty { display: none; }
.gauge { display: block; width: 100%; max-height: 230px; }
.gauge .gl { font: 11px var(--mono); fill: var(--muted); }
.gauge .gu { font: 600 11px var(--mono); fill: var(--muted); letter-spacing: .08em; }
.tilt { display: flex; align-items: center; justify-content: space-around; gap: 10px; padding: 6px 0 10px; }
.compass { width: 58%; max-width: 230px; }
.compass .cl { font: 700 15px var(--mono); fill: var(--ink); }
.compass .cl.n { fill: var(--red); }
.compass .cv { font: 600 22px var(--mono); fill: var(--ink); }
.level { position: relative; width: 112px; height: 112px; border-radius: 50%; background: radial-gradient(circle at 50% 45%, #fbfaf6, #e6e4dd); box-shadow: inset 0 1px 4px rgba(0, 0, 0, .2), 0 0 0 1px var(--line); }
.level .cross::before, .level .cross::after { content: ''; position: absolute; background: #cfccc4; }
.level .cross::before { left: 50%; top: 8px; bottom: 8px; width: 1px; }
.level .cross::after { top: 50%; left: 8px; right: 8px; height: 1px; }
.level .ring { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; border: 1.5px solid #9a978f; }
.level .bubble { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, #a7cf9a 60%, #6fae5d); transition: transform .08s linear; }
.level.flat .ring { border-color: var(--green); }

.readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.ro { background: var(--panel); border-radius: 14px; padding: 10px 12px; box-shadow: inset 0 0 0 1px var(--line); }
.ro > span { font-size: .78rem; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.ro i, .stats i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; }
.ro b { font: 600 1.45rem var(--mono); font-variant-numeric: tabular-nums; }
.ro em { font-style: normal; color: var(--muted); font-size: .85rem; margin-left: 4px; }
.ro small { display: block; font: .7rem var(--mono); color: var(--muted); margin-top: 2px; min-height: 1em; }

.chart-box { position: relative; background: var(--panel); border-radius: 16px; padding: 8px 6px 4px; box-shadow: inset 0 0 0 1px var(--line); }
.chart { display: block; width: 100%; height: 160px; touch-action: none; }
.chart.tall { height: 190px; }
.chart-cap { position: absolute; right: 12px; top: 8px; font: .7rem var(--mono); color: var(--muted); }
.status { color: var(--red); font-size: .88rem; margin: 8px 0 0; min-height: 1.2em; }

/* recordings */
.recs { display: flex; flex-direction: column; gap: 10px; }
.rec { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; border: 0; border-radius: 16px; padding: 14px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.rec b { display: block; }
.rec span { font: .78rem var(--mono); color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; max-width: 40%; }
.badges em, .group h3 em { font: 600 .66rem var(--mono); font-style: normal; letter-spacing: .1em; color: var(--red); border: 1.5px solid currentColor; border-radius: 5px; padding: 2px 4px; }
.empty { text-align: center; padding: 40px 10px; }
.desc { width: 100%; border: 0; border-radius: 12px; padding: 12px 14px; font-size: 1.1rem; font-weight: 600; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.meta { font: .8rem var(--mono); color: var(--muted); margin: 8px 2px 0; }
.group { margin-top: 18px; }
.group h3 { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 8px; font-size: 1rem; }
.group h3 em { color: var(--muted); border: 0; padding: 0; letter-spacing: 0; font-weight: 400; }
.stats { width: 100%; border-collapse: collapse; margin-top: 8px; font: .8rem var(--mono); font-variant-numeric: tabular-nums; }
.stats th { text-align: right; color: var(--muted); font-weight: 600; padding: 4px 6px; }
.stats td { text-align: right; padding: 5px 6px; border-top: 1px solid var(--line); }
.stats td:first-child { text-align: left; font-family: inherit; }
.stats i { margin-right: 6px; vertical-align: middle; }

/* record sheet */
#sheet[hidden] { display: none; }
.sheet-back { position: fixed; inset: 0; background: rgba(35, 39, 43, .35); z-index: 20; }
.sheet-box {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 760px; margin: 0 auto; max-height: 88vh; overflow-y: auto;
  background: var(--body); border-radius: 22px 22px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0, 0, 0, .2);
}
.sheet-box h2 { margin: 0 0 14px; font-size: 1.3rem; }
.sheet-box input[type=text], .sheet-box select { width: 100%; border: 0; border-radius: 12px; padding: 12px 14px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.label { font-size: .78rem; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin: 16px 2px 8px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); font-size: .92rem; }
.check input { width: 18px; height: 18px; accent-color: var(--red); flex: none; }
.check span { flex: 1; min-width: 0; }
.check em { font: 600 .62rem var(--mono); font-style: normal; color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs) + 18px); transform: translate(-50%, 20px); z-index: 30; opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: .9rem; max-width: 86vw; text-align: center; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 600px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.rec-pill[hidden] { display: none; }

.top .applogo { display: none; align-items: center; gap: 8px; flex: 1; font: 600 1.45rem/1 'MeteriaLogo', -apple-system, sans-serif; letter-spacing: -.02em; }
.top .applogo img { width: 30px; height: 30px; margin-top: -3px; }
.top.home .applogo { display: flex; }
.top.home h1 { display: none; }

/* shown in the phone frame of the landing (iframe): room for the status bar and the Dynamic Island */
.framed .top { padding-top: 54px; }
.framed .tabs { padding-bottom: 18px; height: 82px; }

/* record button floats above the tab bar, bottom right */
main { padding-bottom: 96px; }
.framed .recbtn { bottom: calc(82px + 16px); }

/* about */
.about { text-align: center; padding: 18px 6px 0; }
.about .alogo { display: inline-flex; align-items: center; gap: 10px; font: 600 2rem/1 'MeteriaLogo', -apple-system, sans-serif; letter-spacing: -.02em; }
.about .alogo img { width: 46px; height: 46px; margin-top: -4px; }
.about .ver { font: .8rem var(--mono); color: var(--muted); margin: 8px 0 18px; }
.about .made { font-size: 1rem; margin: 0 0 22px; }
.about .made a { color: var(--ink); font-weight: 700; text-decoration: none; border-bottom: 1.5px solid var(--red); }
.about .heart { color: var(--red); }
.about .txt { text-align: left; background: var(--panel); border-radius: 16px; padding: 14px 16px; box-shadow: inset 0 0 0 1px var(--line); font-size: .95rem; color: #3f4448; }
.about .txt p { margin: 0 0 8px; } .about .txt p:last-child { margin: 0; }
.about .acts { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
.about .acts .btn { width: 100%; }
.about .links { display: flex; justify-content: center; gap: 18px; font-size: .9rem; }
.about .links a { color: var(--muted); }
a.btn { display: block; text-align: center; text-decoration: none; }
.about .links { margin-top: 12px; }
