/* Base design tokens and shared styling */

:root {
  --md-sys-color-primary: #23343b;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d9e2e6;
  --md-sys-color-on-primary-container: #0b1518;
  --md-sys-color-secondary: #0075b5;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #cde8f7;
  --md-sys-color-on-secondary-container: #001f2d;
  --md-sys-color-tertiary: #e4003a;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #ffd9e2;
  --md-sys-color-on-tertiary-container: #3f0012;
  --md-sys-color-surface: #f6f8f9;
  --md-sys-color-surface-dim: #dde3e6;
  --md-sys-color-surface-container: #e8ecef;
  --md-sys-color-surface-container-high: #dbe1e4;
  --md-sys-color-surface-container-highest: #d1d9dc;
  --md-sys-color-outline: #718288;
  --md-sys-color-outline-variant: #c1c9cc;
  --md-sys-color-on-surface: #1b2529;
  --md-sys-color-on-surface-variant: #4b5a60;
  --md-sys-color-error: #e4003a;
  --md-sys-color-on-error: #ffffff;
  --brand-success: #3cbc6e;
  --color-brand: #245dff;
  --color-brand-hover: #1d4be8;
  --color-on-brand: #ffffff;
  --button-radius: 12px;

  --md-ref-typeface-brand: "Roboto Flex", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial;

  --md-elevation-1: 0 1px 2px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.08);
  --md-elevation-2: 0 4px 8px rgba(15, 23, 42, 0.12);
  --md-elevation-3: 0 10px 24px rgba(15, 23, 42, 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--md-ref-typeface-brand);
  color: var(--md-sys-color-on-surface);
  background: #f6f8f9;
  line-height: 1.5;
}

body.page {
  min-height: 100vh;
}

body.layout--header-main {
  display: grid;
  grid-template-rows: auto 1fr;
}
body.layout--header-main-footer {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

body.page--radial {
  background: radial-gradient(circle at top, #f4f7f8 0%, #e8ecef 45%, #dbe1e4 100%);
}
body.page--linear {
  background: linear-gradient(160deg, #f4f7f8 0%, #e8ecef 45%, #dbe1e4 100%);
}

main {
  width: 100%;
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}
img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
}
p {
  margin: 0;
}

/* Toast notifications */
.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 4000;
}

.toast {
  min-width: 260px;
  max-width: 520px;
  background: #23343b;
  color: #ffffff;
  box-shadow: var(--md-elevation-2);
  padding: 14px 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  transform: translateY(16px);
  opacity: 0;
  animation: slidein 0.25s ease-out forwards;
}

.toast.err {
  background: var(--md-sys-color-error);
  color: var(--md-sys-color-on-error);
}
.toast.ok {
  background: var(--brand-success);
  color: #23343b;
}

@keyframes slidein {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Navigation */
header.nav-root {
  background: #ffffff;
  z-index: 3100;
}

.nav-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: relative;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--md-sys-color-on-surface);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.nav-logo {
  height: 32px;
  flex-shrink: 0;
}
.nav-title {
  font-size: 18px;
}
.nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.mega {
  position: relative;
}

.mega-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  border: 1px solid rgba(35, 52, 59, 0.12);
  box-shadow: var(--md-elevation-3);
  width: min(960px, calc(100vw - 24px));
  padding: 18px;
  z-index: 3000;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.mega.open .mega-panel {
  display: block;
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.mega-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  z-index: 2900;
  opacity: 0;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.mega-backdrop.show {
  opacity: 1;
}

.nav-action.press {
  transform: scale(0.98);
  transition: transform 0.08s ease;
}

.mega-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 18px;
}

.mega-head {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 600;
  margin-bottom: 6px;
}

.mega-panel a {
  display: block;
  padding: 8px 10px;
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
}

.mega-panel a:hover {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-primary);
}

@media (max-width: 760px) {
  .nav-shell {
    padding: 16px 20px;
  }
  .nav-logo {
    height: 28px;
  }
  .mega.open .mega-panel {
    top: 64px;
    width: calc(100vw - 24px);
    max-height: calc(100vh - 96px);
    overflow: auto;
  }
  .mega-grid {
    grid-template-columns: 1fr;
  }
}

/* Shared components */
.card {
  background: var(--md-sys-color-surface);
  border: 1px solid rgba(35, 52, 59, 0.08);
  box-shadow: var(--md-elevation-2);
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.label {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

.input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container);
  outline: none;
  font-size: 16px;
  letter-spacing: 0.01em;
}

.input:focus {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-surface);
  box-shadow: 0 0 0 4px rgba(35, 52, 59, 0.12);
}

.password-wrapper,
.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
textarea.input {
  min-height: 120px;
  resize: vertical;
}

.row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
}
.row label {
  display: flex;
  gap: 10px;
  align-items: center;
  line-height: 1.4;
}

/* Sign-in page */
body.page--index main {
  display: flex;
  justify-content: center;
  padding: 72px 24px 96px;
}

body.page--index .layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  align-items: center;
  gap: 64px;
  width: 100%;
  max-width: 1080px;
}

body.page--index .intro {
  display: grid;
  gap: 20px;
}

body.page--index .intro-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--md-sys-color-on-primary-container);
}

body.page--index .intro-eyebrow::before {
  content: "";
  width: 32px;
  height: 1px;
  background: var(--md-sys-color-on-primary-container);
  opacity: 0.4;
}

body.page--index .intro h1 {
  font-size: clamp(32px, 4vw, 44px);
  line-height: 1.1;
}
body.page--index .intro p {
  font-size: 16px;
  line-height: 1.7;
  color: var(--md-sys-color-on-surface-variant);
  max-width: 520px;
}

body.page--index .highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
}

body.page--index .chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(0, 117, 181, 0.08);
  color: #0075b5;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

body.page--index .card {
  width: 100%;
  padding: 40px;
  display: grid;
  gap: 24px;
}
body.page--index .form {
  display: grid;
  gap: 24px;
}
body.page--index h1 {
  font-size: 26px;
}
body.page--index .field {
  display: grid;
  gap: 10px;
}

body.page--index .password-row {
  position: relative;
  display: block;
}
body.page--index .password-row .input {
  width: 100%;
  padding-right: 44px;
}
body.page--index .password-row .icon-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 8px;
}

body.page--index footer {
  padding: 32px 24px 40px;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
}

@media (max-width: 960px) {
  body.page--index main {
    padding-top: 56px;
  }
  body.page--index .layout {
    grid-template-columns: 1fr;
    gap: 48px;
    text-align: left;
  }
  body.page--index .intro {
    max-width: 640px;
    margin: 0 auto;
  }
}

@media (max-width: 560px) {
  body.page--index main {
    padding: 48px 18px 72px;
  }
  body.page--index .card {
    padding: 32px 24px;
  }
}

/* App dashboard */
body.page--app main {
  padding: 32px 24px 48px;
}

body.page--app .grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  max-width: 1120px;
  margin: 0 auto;
}

body.page--app .card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
body.page--app .card .card__body {
  flex-grow: 1;
}

body.page--app .card:hover {
  transform: translateY(-2px);
  box-shadow: var(--md-elevation-3);
}

body.page--app .title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 17px;
}

body.page--app .status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--md-sys-color-on-tertiary-container);
  background: var(--md-sys-color-tertiary-container);
  border: 1px solid rgba(228, 0, 58, 0.24);
  padding: 4px 12px;
}

body.page--app .status-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  background: currentColor;
  opacity: 0.6;
  box-shadow: 0 0 0 2px rgba(228, 0, 58, 0.16);
}

body.page--app .desc {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
  line-height: 1.5;
}
body.page--app .card .btn {
  margin-top: auto;
}

/* Knowledge base */
body.page--knowledge-base main {
  padding: 48px 24px 72px;
  display: grid;
  gap: 32px;
}

body.page--knowledge-base .hero {
  width: min(960px, 100%);
  margin: 0 auto;
  background: var(--md-sys-color-surface);
  border: 1px solid rgba(35, 52, 59, 0.08);
  box-shadow: var(--md-elevation-3);
  padding: 36px;
  display: grid;
  gap: 16px;
}

body.page--knowledge-base .chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
  border: 1px solid rgba(228, 0, 58, 0.24);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

body.page--knowledge-base .chip::before {
  content: "";
  width: 8px;
  height: 8px;
  background: currentColor;
  opacity: 0.6;
  box-shadow: 0 0 0 3px rgba(228, 0, 58, 0.18);
}

body.page--knowledge-base .hero p {
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.7;
}

body.page--knowledge-base .hero-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

body.page--knowledge-base .resource-grid {
  width: min(960px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

body.page--knowledge-base .resource-card {
  background: var(--md-sys-color-surface);
  border: 1px solid rgba(35, 52, 59, 0.08);
  box-shadow: var(--md-elevation-2);
  padding: 28px;
  display: grid;
  gap: 16px;
}

body.page--knowledge-base .resource-card.primary {
  box-shadow: var(--md-elevation-3);
}

body.page--knowledge-base .tonal-panel {
  width: min(960px, 100%);
  margin: 0 auto;
  background: var(--md-sys-color-surface-container);
  border: 1px solid rgba(35, 52, 59, 0.06);
  padding: 28px;
  display: grid;
  gap: 16px;
}

body.page--knowledge-base .tonal-panel p {
  color: var(--md-sys-color-on-surface-variant);
}

/* Secure Send */
body.page--secure-send main {
  padding: 32px 24px 48px;
}

body.page--secure-send .card {
  max-width: 880px;
  margin: 0 auto;
  box-shadow: var(--md-elevation-3);
  padding: 28px;
  display: grid;
  gap: 20px;
}

body.page--secure-send .subtitle {
  margin: 6px 0 0;
  color: var(--md-sys-color-on-surface-variant);
}

body.page--secure-send .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  column-gap: 24px;
  row-gap: 16px;
  align-items: start;
}

body.page--secure-send .field {
  display: grid;
  gap: 10px;
  min-width: 0;
}

body.page--secure-send .box {
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid rgba(35, 52, 59, 0.08);
  padding: 16px;
  word-break: break-all;
}

body.page--secure-send #result {
  display: none;
  margin-top: 14px;
}
body.page--secure-send #result .buttons {
  justify-content: flex-start;
  margin-top: 10px;
}

body.page--secure-send .hint {
  margin: 8px 0 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

body.page--secure-send .password-wrapper {
  position: relative;
  display: block;
  overflow: hidden;
}
body.page--secure-send .password-wrapper .input {
  width: 100%;
  padding-right: 44px;
}
body.page--secure-send .password-wrapper .icon-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
}

@media (max-width: 760px) {
  body.page--secure-send main {
    padding: 24px 16px 40px;
  }
  body.page--secure-send .card {
    padding: 22px;
  }
}

/* View Secret */
body.page--view-secret main {
  display: grid;
  place-items: center;
  padding: 32px 24px 48px;
}

body.page--view-secret .card {
  width: min(760px, 100%);
  box-shadow: var(--md-elevation-3);
  padding: 28px;
  display: grid;
  gap: 20px;
}

body.page--view-secret h1 {
  font-size: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}
body.page--view-secret .state {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
}

body.page--view-secret .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

body.page--view-secret .label {
  margin: 8px 0 6px;
}

body.page--view-secret .box,
body.page--view-secret .copyable-field {
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid rgba(35, 52, 59, 0.08);
  padding: 16px;
  word-break: break-all;
}

body.page--view-secret .copyable-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: background 0.18s ease;
}
body.page--view-secret .copyable-field:hover {
  background: var(--md-sys-color-surface-container);
}

body.page--view-secret .copy-icon {
  background: none;
  border: 0;
  padding: 0;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1;
}

body.page--view-secret .info {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  padding: 16px;
  display: grid;
  gap: 8px;
}

body.page--view-secret #content {
  display: none;
}

@media (max-width: 760px) {
  body.page--view-secret main {
    padding: 24px 16px 40px;
  }
}

/* Our websites */
body.page--our-websites main {
  padding: 48px 24px 72px;
  display: grid;
  gap: 32px;
}

body.page--our-websites .intro {
  width: min(960px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 16px;
  text-align: left;
}
body.page--our-websites .intro h1 {
  font-size: clamp(28px, 4vw, 36px);
}
body.page--our-websites .intro p {
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.65;
}

body.page--our-websites .sites {
  width: min(960px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.page--our-websites .site-card {
  background: var(--md-sys-color-surface);
  border: 1px solid rgba(35, 52, 59, 0.08);
  box-shadow: var(--md-elevation-2);
  padding: 28px;
  display: grid;
  gap: 20px;
}

body.page--our-websites .site-header {
  display: flex;
  gap: 16px;
  align-items: center;
}

body.page--our-websites .site-logo {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 20px;
  color: #ffffff;
  background: #0075b5;
  box-shadow: var(--md-elevation-1);
}

body.page--our-websites .site-title {
  font-size: 22px;
}
body.page--our-websites .site-desc {
  color: var(--md-sys-color-on-surface-variant);
}

body.page--our-websites .site-meta {
  display: grid;
  gap: 12px;
}
body.page--our-websites .site-meta dt {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--md-sys-color-on-surface-variant);
}
body.page--our-websites .site-meta dd {
  margin: 4px 0 0;
  font-size: 15px;
}
body.page--our-websites .site-meta a {
  color: #0075b5;
  font-weight: 600;
  text-decoration: none;
}
body.page--our-websites .site-meta a:hover {
  text-decoration: underline;
}

@media (max-width: 720px) {
  body.page--our-websites main {
    padding: 32px 16px 60px;
  }
  body.page--our-websites .sites {
    grid-template-columns: 1fr;
  }
}

/* Knowledge base responsive tweaks */
@media (max-width: 760px) {
  body.page--knowledge-base main {
    padding: 32px 16px 60px;
  }
  body.page--knowledge-base .hero {
    padding: 28px;
  }
  body.page--knowledge-base .hero-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
