/* MobileNtfy PWA - styles. No frameworks; light and dark mode follow the phone.
   Layout rule: nothing may be wider than the screen. Every grid/flex child can shrink
   (min-width: 0) and long text wraps, so the page always fits the phone's width. */

:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1a1f29;
  --muted: #5d6675;
  --line: #e2e6ec;
  --accent: #16785a; /* brand colour, filled in by Setup\Build-Brand.ps1 */
  --accent-text: #ffffff;
  --danger: #c93c37;
  --ok: #1a7f37;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --card: #181c24;
    --text: #e8ebf0;
    --muted: #9aa3b2;
    --line: #2a303b;
    --accent: #4c8dff;
    --danger: #ff6b66;
    --ok: #4ac26b;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img { max-width: 100%; height: auto; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden; /* safety net: never scroll sideways */
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.top { display: flex; align-items: center; gap: 10px; padding: 18px 2px 10px; min-width: 0; }
.top img { border-radius: 9px; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 6px; }
p { margin: 0 0 12px; }
/* minmax(0, 1fr): the column follows the screen width instead of growing with its content. */
main { width: 100%; max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.top { max-width: 560px; margin: 0 auto; }

.card { min-width: 0; overflow-wrap: anywhere; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.card.subtle { background: transparent; }
.hint { color: var(--muted); font-size: 14px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
ol { padding-left: 20px; margin: 6px 0 12px; }

/* Code field and Connect button side by side. Only this form: the dialog's form must stay a normal column. */
#pair-form { display: flex; gap: 8px; width: 100%; min-width: 0; }
input {
  flex: 1 1 0; min-width: 0; width: 100%;
  font: 600 18px/1 ui-monospace, "SF Mono", Consolas, monospace;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 12px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 0; border-radius: 10px; padding: 12px 14px;
  background: var(--accent); color: var(--accent-text);
  max-width: 100%; white-space: nowrap;
}
#pair-form button { flex: 0 0 auto; }
button:disabled { opacity: 0.55; cursor: default; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--line); margin-top: 4px; }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
button.link { background: none; color: var(--accent); padding: 4px; font-weight: 500; }

.status { margin: 10px 0 0; min-height: 1.4em; font-size: 15px; }
.status.ok { color: var(--ok); }
.status.error { color: var(--danger); }

#messages { list-style: none; margin: 8px 0 0; padding: 0; }
#messages li { border-top: 1px solid var(--line); padding: 10px 0; }
#messages li:first-child { border-top: 0; }
#messages li.highlight { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 10px; margin: 0 -8px; padding: 10px 8px; transition: background 1s; }
.msg-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); min-width: 0; }
.msg-app { font-weight: 600; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-head time { flex: 0 0 auto; }
.msg-body { margin-top: 2px; overflow-wrap: anywhere; white-space: pre-line; } /* keep line breaks from the PC */
.msg-link { display: block; max-width: 100%; margin-top: 4px; color: var(--accent); font-size: 14px; word-break: break-all; }

.msg-body a { color: var(--accent); word-break: break-all; }
.version { max-width: 560px; margin: 18px auto 0; text-align: center; font-size: 12px; color: var(--muted); }

/* Bars at the top: update ready, wrong browser, phone not connected. */
.bar {
  max-width: 560px; width: 100%; margin: 0 auto 12px; padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card); color: var(--text); border: 1px solid var(--accent); border-radius: 12px;
  font: inherit; font-size: 15px; font-weight: 400; text-align: left;
}
.bar[hidden] { display: none; }
.bar button, .bar .button { padding: 8px 14px; flex: 0 0 auto; }
.bar.warn { border-color: #d29922; }
.bar.error { border-color: var(--danger); cursor: pointer; }
.bar-action { color: var(--danger); font-weight: 600; flex: 0 0 auto; }
a.button {
  display: inline-block; text-decoration: none; font-weight: 600; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); white-space: nowrap;
}

h3 { font-size: 15px; margin: 16px 0 4px; }
.hint.ok, #pair-hint.ok { color: var(--ok); font-weight: 600; }

/* Connection status */
.status-box { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; margin: 6px 0 8px; }
.status-box.good { background: color-mix(in srgb, var(--ok) 12%, transparent); }
.status-box.bad { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.status-box p { margin: 2px 0 0; }
.status-icon { font-size: 20px; line-height: 1.2; }
.pcs { margin: 0 0 4px; padding-left: 20px; }
.pcs li { margin: 2px 0; }

/* Tips */
details.card summary { cursor: pointer; font-weight: 600; font-size: 17px; }
.tips { margin: 10px 0 0; padding-left: 18px; }
.tips li { margin: 6px 0; }
.tips a { color: var(--accent); }

/* Confirmation dialog: small, centred, short text, compact buttons. */
dialog {
  width: min(300px, calc(100vw - 64px)); max-width: none; margin: auto; padding: 16px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text);
  font-size: 15px; line-height: 1.4;
}
dialog::backdrop { background: rgb(0 0 0 / 45%); }
dialog h2 { font-size: 16px; margin: 0 0 6px; }
dialog p { margin: 0; color: var(--muted); }
dialog form { display: block; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dialog-buttons button { padding: 8px 14px; font-size: 15px; }
button.danger-solid { background: var(--danger); color: #fff; }
