/* Material 3 look, matching the CODED7 Android app. */
:root {
  --primary: #415f91; --on-primary: #fff; --primary-container: #d6e3ff;
  --secondary-container: #dae2f9; --on-secondary-container: #3e4759;
  --surface: #f9f9ff; --surface-low: #f3f3fa; --surface-container: #ededf4; --surface-high: #e7e8ee; --surface-highest: #e2e2e9;
  --on-surface: #191c20; --on-surface-variant: #44474e; --outline: #74777f; --outline-variant: #c4c6d0;
  --error: #ba1a1a; --inverse-surface: #2e3036; --inverse-on-surface: #eff0f7; --inverse-primary: #aac7ff;
  --console-bg: #0a0f0c; --console-fg: #3ddc84;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #aac7ff; --on-primary: #0a305f; --primary-container: #284777;
    --secondary-container: #3e4759; --on-secondary-container: #dae2f9;
    --surface: #111318; --surface-low: #191c20; --surface-container: #1d2024; --surface-high: #282a2f; --surface-highest: #33353a;
    --on-surface: #e2e2e9; --on-surface-variant: #c4c6d0; --outline: #8e9099; --outline-variant: #44474e;
    --error: #ffb4ab; --inverse-surface: #e2e2e9; --inverse-on-surface: #2e3036; --inverse-primary: #415f91;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--surface); color: var(--on-surface);
  font: 16px/1.5 Roboto, "Google Sans Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  letter-spacing: .03px;
}
a { color: var(--primary); }
svg { width: 24px; height: 24px; fill: currentColor; flex: none; }

/* top app bar */
.appbar {
  position: sticky; top: 0; z-index: 4; height: 64px; display: flex; align-items: center;
  padding: 0 max(4px, calc((100% - 640px) / 2 + 4px)) 0 max(16px, calc((100% - 640px) / 2 + 16px));
  background: var(--surface); transition: background .2s;
}
.appbar.scrolled { background: var(--surface-container); }
.appbar h1 { flex: 1; margin: 0; font-size: 22px; font-weight: 400; line-height: 28px; }
.icon-btn {
  width: 48px; height: 48px; border: 0; border-radius: 50%; background: none; color: var(--on-surface-variant);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: color-mix(in srgb, var(--on-surface-variant) 8%, transparent); }

.content { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(112px + env(safe-area-inset-bottom)); }

/* section headers (titleSmall, primary) */
.section { margin: 28px 0 10px; font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: .1px; color: var(--primary); }
.section.first { margin-top: 0; }

/* segmented / toggle group */
.toggle-group { display: flex; }
.toggle-group button {
  flex: 1; height: 40px; border: 1px solid var(--outline); background: transparent; color: var(--on-surface);
  font: inherit; font-size: 14px; font-weight: 500; letter-spacing: .1px; cursor: pointer;
}
.toggle-group button:first-child { border-radius: 20px 0 0 20px; }
.toggle-group button:last-child { border-radius: 0 20px 20px 0; border-left: 0; }
.toggle-group button[aria-checked="true"] { background: var(--secondary-container); color: var(--on-secondary-container); }

/* outlined text field */
.tf { position: relative; margin-top: 12px; }
.tf.top-gap { margin-top: 16px; }
.section + .tf { margin-top: 0; }
.tf input, .tf textarea, .tf select {
  display: block; width: 100%; height: 56px; padding: 16px; font: inherit; color: var(--on-surface);
  background: transparent; border: 1px solid var(--outline); border-radius: 4px; outline: none; appearance: none;
}
.tf textarea { height: auto; min-height: 136px; resize: vertical; padding-top: 16px; }
.tf.has-start input { padding-left: 52px; }
.tf.has-end input, .tf.select select { padding-right: 52px; }
.tf input:hover, .tf textarea:hover, .tf select:hover { border-color: var(--on-surface); }
.tf input:focus, .tf textarea:focus, .tf select:focus { border: 2px solid var(--primary); padding-left: 15px; }
.tf.has-start input:focus { padding-left: 51px; }
.tf label {
  position: absolute; left: 12px; top: 16px; padding: 0 4px; line-height: 24px; color: var(--on-surface-variant);
  pointer-events: none; background: var(--surface); transition: top .15s, font-size .15s, left .15s, color .15s;
  max-width: calc(100% - 24px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tf.has-start label { left: 48px; }
.tf input:focus + label, .tf textarea:focus + label, .tf input:not(:placeholder-shown) + label,
.tf textarea:not(:placeholder-shown) + label, .tf label.floated {
  top: -10px; left: 12px; font-size: 12px; line-height: 20px;
}
.tf input:focus + label, .tf textarea:focus + label, .tf select:focus + label { color: var(--primary); }
.tf .start { position: absolute; left: 12px; top: 16px; color: var(--on-surface-variant); pointer-events: none; }
.tf .end, .tf .end-static { position: absolute; right: 4px; top: 4px; color: var(--on-surface-variant); }
.tf .end-static { right: 12px; top: 16px; pointer-events: none; }
.tf .end { width: 48px; height: 48px; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.tf select { cursor: pointer; }
.tf select option { background: var(--surface-container); color: var(--on-surface); }
.helper { padding: 4px 16px 0; font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--on-surface-variant); }
.helper:empty { display: none; }
.tf.error input, .tf.error textarea { border: 2px solid var(--error); }
.tf.error label, .tf.error .helper { color: var(--error); }

/* strength (LinearProgressIndicator) */
.strength-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.progress { position: relative; flex: 1; height: 6px; display: flex; gap: 4px; }
.progress span { height: 6px; border-radius: 3px; transition: width .25s, background .25s; width: 0; }
.progress i { flex: 1; height: 6px; border-radius: 3px; background: var(--secondary-container); position: relative; }
.progress i::after { content: ""; position: absolute; right: 1px; top: 1px; width: 4px; height: 4px; border-radius: 50%; background: var(--primary); }
#strength-text { font-size: 12px; line-height: 16px; letter-spacing: .4px; min-width: 56px; }

.row { display: flex; align-items: center; margin-top: 4px; }
.spacer { flex: 1; }

/* buttons */
button, .filled, .outlined-btn, .text-btn { font-family: inherit; }
.filled, .outlined-btn, .text-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; border-radius: 20px;
  font-size: 14px; font-weight: 500; letter-spacing: .1px; cursor: pointer; text-decoration: none; user-select: none;
}
.filled svg, .outlined-btn svg, .text-btn svg { width: 18px; height: 18px; }
.filled { background: var(--primary); color: var(--on-primary); border: 0; padding: 0 24px 0 16px; }
.filled:hover { box-shadow: 0 1px 2px rgba(0,0,0,.3), 0 1px 3px 1px rgba(0,0,0,.15); }
.filled:disabled { background: color-mix(in srgb, var(--on-surface) 12%, transparent); color: color-mix(in srgb, var(--on-surface) 38%, transparent); box-shadow: none; cursor: default; }
.outlined-btn { background: transparent; color: var(--primary); border: 1px solid var(--outline); padding: 0 24px 0 16px; }
.text-btn { background: transparent; color: var(--primary); border: 0; padding: 0 12px; }
.text-btn:hover, .outlined-btn:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.filled.big { position: relative; width: 100%; height: 56px; border-radius: 28px; margin-top: 24px; font-size: 14px; }
.filled.big svg { position: absolute; left: 24px; width: 20px; height: 20px; }
#decrypt-btn { margin-top: 16px; }

.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 16px 0 8px; margin: 8px 0;
  border: 1px solid var(--outline); border-radius: 8px; background: transparent; color: var(--on-surface);
  font-size: 14px; font-weight: 500; letter-spacing: .1px; cursor: pointer; max-width: 100%;
}
.chip svg { width: 18px; height: 18px; color: var(--primary); }
.chip .x { color: var(--on-surface-variant); margin-right: -8px; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.on { background: var(--secondary-container); border-color: transparent; color: var(--on-secondary-container); }
.chip:hover { background: color-mix(in srgb, var(--on-surface) 8%, transparent); }
.chip.on:hover { background: color-mix(in srgb, var(--secondary-container) 85%, var(--on-surface)); }

/* indeterminate progress */
.indeterminate { margin-top: 12px; height: 4px; background: var(--secondary-container); border-radius: 2px; overflow: hidden; }
.indeterminate span { display: block; height: 100%; width: 40%; background: var(--primary); border-radius: 2px; animation: ind 1.4s infinite ease-in-out; }
@keyframes ind { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* cards */
.card { border-radius: 12px; overflow: hidden; }
.card.outlined { border: 1px solid var(--outline-variant); background: var(--surface); }
.filled-card { background: var(--surface-highest); margin-top: 16px; }
.pick { display: flex; align-items: center; gap: 16px; padding: 16px; margin-top: 12px; cursor: pointer; }
.pick:hover, .pick.over { background: color-mix(in srgb, var(--on-surface) 6%, var(--surface)); }
#image-card { margin-top: 0; }
.thumb { width: 56px; height: 56px; flex: none; display: grid; place-items: center; background: var(--surface-highest); color: var(--on-surface-variant); overflow: hidden; }
.big-thumb .thumb { width: 64px; height: 64px; }
.thumb svg { width: 28px; height: 28px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.pick-text { min-width: 0; flex: 1; }
.title { font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: .15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { font-size: 14px; line-height: 20px; letter-spacing: .25px; color: var(--on-surface-variant); }
.meta.pre { white-space: pre-line; margin-top: 2px; }
.cover { display: block; width: 100%; height: 220px; object-fit: cover; }
.contain { display: block; width: 100%; max-height: 360px; object-fit: contain; background: var(--surface-high); }
.card-body { padding: 16px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.label { font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: .1px; color: var(--primary); }
.dec-text { margin-top: 8px; font-size: 16px; line-height: 24px; letter-spacing: .5px; white-space: pre-wrap; word-break: break-word; user-select: text; max-height: 60vh; overflow: auto; }
.small-note { margin: 16px 0 0; font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--on-surface-variant); }

/* hacker console */
.console-card { margin-top: 16px; height: 280px; border-radius: 16px; background: var(--console-bg); overflow: hidden; }
.console-card pre {
  margin: 0; height: 100%; padding: 12px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden;
  font: 11.5px/1.32 "Roboto Mono", "Droid Sans Mono", ui-monospace, Menlo, Consolas, monospace; color: var(--console-fg); white-space: pre;
}
.console-card .d { color: #2f6b47; }
.console-card .g { color: #3ddc84; }
.console-card .b { color: #e6ffe9; font-weight: 700; }
.console-card .r { color: #ff5c5c; font-weight: 700; }
.console-card .big { font-size: 1.9em; line-height: 1.25; }
.console-card .okc { color: #4ade80; font-weight: 700; }
.shake { animation: shake .45s; }
@keyframes shake { 14% { transform: translateX(22px); } 28% { transform: translateX(-22px); } 42% { transform: translateX(16px); } 57% { transform: translateX(-16px); } 71% { transform: translateX(8px); } 85% { transform: translateX(-8px); } }

/* bottom navigation */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; justify-content: center;
  height: calc(80px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface-container);
}
.bottom-nav button {
  flex: 1; max-width: 320px; border: 0; background: none; color: var(--on-surface-variant); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 12px;
  font-size: 12px; font-weight: 500; letter-spacing: .5px; line-height: 16px;
}
.bottom-nav .ind { width: 64px; height: 32px; border-radius: 16px; display: grid; place-items: center; transition: background .2s; }
.bottom-nav button[aria-current="page"] { color: var(--on-surface); font-weight: 700; }
.bottom-nav button[aria-current="page"] .ind { background: var(--secondary-container); color: var(--on-secondary-container); }
.bottom-nav button:hover .ind { background: color-mix(in srgb, var(--on-surface) 8%, transparent); }
.bottom-nav button[aria-current="page"]:hover .ind { background: var(--secondary-container); }

/* snackbar */
.snackbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 6;
  width: min(608px, calc(100% - 16px)); padding: 14px 16px; border-radius: 4px; background: var(--inverse-surface); color: var(--inverse-on-surface);
  font-size: 14px; line-height: 20px; letter-spacing: .25px; box-shadow: 0 3px 5px rgba(0,0,0,.2), 0 1px 18px rgba(0,0,0,.12);
  animation: snack .15s ease-out;
}
@keyframes snack { from { opacity: 0; transform: translate(-50%, 8px); } }

/* dialog */
.scrim { position: fixed; inset: 0; z-index: 8; background: rgba(0,0,0,.32); display: grid; place-items: center; padding: 24px; }
.dialog {
  width: min(560px, 100%); max-height: calc(100vh - 48px); overflow: auto; background: var(--surface-high);
  border-radius: 28px; padding: 24px; color: var(--on-surface-variant); font-size: 14px; line-height: 20px; letter-spacing: .25px;
}
.dialog h3 { margin: 0 0 16px; color: var(--on-surface); font-size: 24px; line-height: 32px; font-weight: 400; }
.dialog p { margin: 0 0 14px; }
.dialog-actions { display: flex; justify-content: flex-end; margin: 8px -12px -4px 0; }

@media (prefers-reduced-motion: reduce) { .shake, .indeterminate span { animation: none; } }
.sprite { position: absolute; width: 0; height: 0; }
