:root {
  color-scheme: light dark;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --canvas: #f5f5f7;
  --surface: #ffffff;
  --surface-subtle: #fafafc;
  --surface-hover: rgba(0, 0, 0, 0.035);
  --sidebar: rgba(242, 242, 247, 0.84);
  --list-pane: rgba(255, 255, 255, 0.72);
  --input-bg: rgba(118, 118, 128, 0.085);
  --input-focus-bg: #ffffff;

  --ink: #1d1d1f;
  --ink-secondary: #6e6e73;
  --ink-tertiary: #8e8e93;

  --hairline: rgba(0, 0, 0, 0.075);
  --hairline-strong: rgba(0, 0, 0, 0.13);

  --accent: #007aff;
  --accent-hover: #0066d6;
  --accent-tint: rgba(0, 122, 255, 0.11);
  --accent-ring: rgba(0, 122, 255, 0.24);

  --green: #248a3d;
  --green-solid: #34c759;
  --green-tint: rgba(52, 199, 89, 0.14);
  --red: #d70015;
  --red-solid: #ff3b30;
  --red-tint: rgba(255, 59, 48, 0.11);
  --amber: #b25000;
  --amber-tint: rgba(255, 149, 0, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 0 0 0.5px var(--hairline);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 10px 28px rgba(0, 0, 0, 0.04), 0 0 0 0.5px var(--hairline);
  --shadow-auth: 0 24px 64px rgba(0, 0, 0, 0.09), 0 2px 10px rgba(0, 0, 0, 0.04), 0 0 0 0.5px var(--hairline);
  --shadow-toast: 0 12px 32px rgba(0, 0, 0, 0.18), 0 0 0 0.5px rgba(255, 255, 255, 0.12);

  --toast-bg: rgba(29, 29, 31, 0.9);
  --toast-ink: #ffffff;
  --auth-glow-1: rgba(0, 122, 255, 0.12);
  --auth-glow-2: rgba(94, 92, 230, 0.09);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #000000;
    --surface: #1c1c1e;
    --surface-subtle: #242426;
    --surface-hover: rgba(255, 255, 255, 0.06);
    --sidebar: rgba(28, 28, 30, 0.86);
    --list-pane: rgba(20, 20, 22, 0.82);
    --input-bg: rgba(118, 118, 128, 0.22);
    --input-focus-bg: #2c2c2e;

    --ink: #f5f5f7;
    --ink-secondary: #98989d;
    --ink-tertiary: #636366;

    --hairline: rgba(255, 255, 255, 0.09);
    --hairline-strong: rgba(255, 255, 255, 0.16);

    --accent: #0a84ff;
    --accent-hover: #3399ff;
    --accent-tint: rgba(10, 132, 255, 0.2);
    --accent-ring: rgba(10, 132, 255, 0.34);

    --green: #30d158;
    --green-solid: #30d158;
    --green-tint: rgba(48, 209, 88, 0.18);
    --red: #ff6961;
    --red-solid: #ff453a;
    --red-tint: rgba(255, 69, 58, 0.18);
    --amber: #ffd60a;
    --amber-tint: rgba(255, 214, 10, 0.16);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 0 0 0.5px var(--hairline);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.35), 0 0 0 0.5px var(--hairline);
    --shadow-auth: 0 28px 72px rgba(0, 0, 0, 0.55), 0 0 0 0.5px var(--hairline-strong);
    --toast-bg: rgba(44, 44, 46, 0.94);
    --auth-glow-1: rgba(10, 132, 255, 0.18);
    --auth-glow-2: rgba(94, 92, 230, 0.16);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #000000;
  --surface: #1c1c1e;
  --surface-subtle: #242426;
  --surface-hover: rgba(255, 255, 255, 0.06);
  --sidebar: rgba(28, 28, 30, 0.86);
  --list-pane: rgba(20, 20, 22, 0.82);
  --input-bg: rgba(118, 118, 128, 0.22);
  --input-focus-bg: #2c2c2e;

  --ink: #f5f5f7;
  --ink-secondary: #98989d;
  --ink-tertiary: #636366;

  --hairline: rgba(255, 255, 255, 0.09);
  --hairline-strong: rgba(255, 255, 255, 0.16);

  --accent: #0a84ff;
  --accent-hover: #3399ff;
  --accent-tint: rgba(10, 132, 255, 0.2);
  --accent-ring: rgba(10, 132, 255, 0.34);

  --green: #30d158;
  --green-solid: #30d158;
  --green-tint: rgba(48, 209, 88, 0.18);
  --red: #ff6961;
  --red-solid: #ff453a;
  --red-tint: rgba(255, 69, 58, 0.18);
  --amber: #ffd60a;
  --amber-tint: rgba(255, 214, 10, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 0 0 0.5px var(--hairline);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.35), 0 0 0 0.5px var(--hairline);
  --shadow-auth: 0 28px 72px rgba(0, 0, 0, 0.55), 0 0 0 0.5px var(--hairline-strong);
  --toast-bg: rgba(44, 44, 46, 0.94);
  --auth-glow-1: rgba(10, 132, 255, 0.18);
  --auth-glow-2: rgba(94, 92, 230, 0.16);
}

:root[data-theme="light"] {
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  min-width: 280px;
  margin: 0;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--canvas);
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.5; }
h1, h2, h3, p, dl, dd, dt { margin: 0; }
a, button, input, textarea, code { -webkit-tap-highlight-color: transparent; }
::selection { background: var(--accent-tint); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  z-index: 40;
  top: 12px;
  left: 12px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transform: translateY(-200%);
  transition: transform 0.2s var(--ease);
}
.skip-link:focus { transform: none; }

/* Theme icon visibility */
.icon-sun { display: none; }
.icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* App shell */
.app {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100vh;
  overflow-y: auto;
  padding: 20px 14px 14px;
  background: var(--sidebar);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-right: 1px solid var(--hairline);
}

.sidebar-top {
  padding: 2px 6px 4px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
}
.brand-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 680;
  letter-spacing: -0.025em;
  line-height: 1.15;
}
.brand-text small {
  display: block;
  margin-top: 2px;
  color: var(--ink-tertiary);
  font-size: 10.5px;
  font-weight: 640;
  letter-spacing: 0.08em;
}

.brand-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: #ffffff;
  background: linear-gradient(180deg, #329aff 0%, #007aff 62%, #0062d1 100%);
  box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 0.38), 0 3px 10px rgba(0, 122, 255, 0.28);
}
.brand-icon svg {
  width: 20px;
  height: 20px;
}
.brand-icon-lg {
  width: 52px;
  height: 52px;
  border-radius: 15px;
}
.brand-icon-lg svg {
  width: 28px;
  height: 28px;
}

.navigation, .categories {
  display: grid;
  gap: 2px;
}

.nav-link, .category-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 36px;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  font-size: 14px;
  font-weight: 520;
  color: var(--ink);
  transition: background-color 0.14s var(--ease), color 0.14s var(--ease);
}
.nav-link:hover, .category-button:hover {
  background: var(--surface-hover);
}
.nav-link.is-current {
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 600;
}
.nav-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 19px;
  height: 19px;
  color: var(--ink-secondary);
}
.nav-link.is-current .nav-icon {
  color: var(--accent);
}
.nav-icon svg {
  width: 18px;
  height: 18px;
}

.categories h2 {
  margin: 4px 10px 6px;
  color: var(--ink-tertiary);
  font-size: 11.5px;
  font-weight: 640;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.category-button {
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  font-size: 13.5px;
  font-weight: 500;
}
.category-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.category-count {
  flex: none;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--ink-secondary);
  background: var(--surface-hover);
}
.category-button[aria-pressed="true"] {
  background: var(--accent);
  color: #ffffff;
  font-weight: 560;
}
.category-button[aria-pressed="true"] .category-count {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.22);
}

.sidebar-account {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}
.account-link {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  padding: 6px 7px;
  border-radius: 10px;
  transition: background-color 0.14s var(--ease);
}
.account-link:hover { background: var(--surface-hover); }
.account-meta { min-width: 0; }
.account-meta strong, .account-meta small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-meta strong { font-size: 13px; font-weight: 600; }
.account-meta small { font-size: 11px; color: var(--ink-secondary); }

.sidebar-account-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}
.icon-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-secondary);
  transition: background-color 0.14s var(--ease), color 0.14s var(--ease);
}
.icon-button:hover {
  background: var(--surface-hover);
  color: var(--ink);
}
.icon-button svg { width: 17px; height: 17px; }

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(145deg, #5ac8fa, #007aff);
  color: #ffffff;
  font-size: 13px;
  font-weight: 660;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.avatar-md {
  width: 40px;
  height: 40px;
  font-size: 15px;
  background: var(--input-bg);
  color: var(--ink);
  box-shadow: none;
}
.avatar-owner {
  background: linear-gradient(145deg, #329aff, #007aff);
  color: #ffffff;
}

/* Main area */
.main {
  min-width: 0;
  width: 100%;
}
.main-workspace {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.main-workspace > .notices {
  margin: 14px 24px 0;
}
.main-workspace > .workspace {
  flex: 1;
  min-height: 0;
}

.page-wrap {
  width: 100%;
  max-width: 920px;
  margin-inline: auto;
  padding: 36px clamp(20px, 4vw, 48px) 72px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-heading { min-width: 0; }
.page-heading h1 {
  font-family: var(--font-display);
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.page-heading p {
  margin-top: 6px;
  color: var(--ink-secondary);
  font-size: 14.5px;
}
.history-source-note {
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink-tertiary);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 560;
}
.back-link:hover { opacity: 0.78; }

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 16px;
  border: 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 580;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: background-color 0.14s var(--ease), transform 0.12s var(--ease), box-shadow 0.14s var(--ease), opacity 0.14s var(--ease);
}
.button:active { transform: scale(0.975); }
.button svg { width: 15px; height: 15px; flex: none; }

.button-compact {
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 9px;
  font-size: 13px;
}
.button-lg {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 15px;
}

.button-primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 3px rgba(0, 122, 255, 0.25);
}
.button-primary:hover { background: var(--accent-hover); }

.button-quiet {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.button-quiet:hover { background: var(--surface-subtle); }

.pill-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 11px;
  border: 0;
  border-radius: 7px;
  background: var(--input-bg);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 560;
  white-space: nowrap;
  transition: background-color 0.14s var(--ease), color 0.14s var(--ease), transform 0.1s var(--ease);
}
.pill-action:hover { background: var(--surface-hover); color: var(--accent); }
.pill-action:active { transform: scale(0.96); }
.pill-action-accent {
  background: var(--accent-tint);
  color: var(--accent);
}
.pill-action-accent:hover {
  background: var(--accent);
  color: #ffffff;
}
.pill-action.is-copied {
  background: var(--green-tint);
  color: var(--green);
}

/* Split-View Workspace (macOS Passwords style) */
.split-layout {
  display: grid;
  grid-template-columns: 336px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--list-pane);
  border-right: 1px solid var(--hairline);
}

.list-header {
  flex: none;
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--hairline);
}
.list-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.list-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.list-title-group h1 {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.count-pill {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--input-bg);
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--ink-tertiary);
  transition: background-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.search:focus-within {
  background: var(--input-focus-bg);
  box-shadow: 0 0 0 3px var(--accent-ring), 0 0 0 1px var(--accent);
}
.search-svg {
  width: 15px;
  height: 15px;
  flex: none;
}
.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 6px 0;
  background: transparent;
  color: var(--ink);
  font-size: 13.5px;
}
.search input::placeholder { color: var(--ink-tertiary); }
.search-kbd {
  flex: none;
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink-tertiary);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 560;
  box-shadow: var(--shadow-sm);
}

.list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}
.service-list {
  display: grid;
  gap: 2px;
}

.service-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  text-align: left;
  transition: background-color 0.12s var(--ease), color 0.12s var(--ease);
}
.service-row:hover {
  background: var(--surface-hover);
}
.service-row.is-selected {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.22);
}
.service-row-text {
  min-width: 0;
}
.service-row-text strong, .service-row-text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.service-row-text strong {
  font-size: 14px;
  font-weight: 580;
  letter-spacing: -0.01em;
}
.service-row-text small {
  margin-top: 1px;
  font-size: 12.5px;
  color: var(--ink-secondary);
}
.service-row.is-selected .service-row-text small {
  color: rgba(255, 255, 255, 0.8);
}
.row-chevron {
  width: 14px;
  height: 14px;
  color: var(--ink-tertiary);
  opacity: 0;
  transition: opacity 0.14s var(--ease);
}
.service-row:hover .row-chevron { opacity: 0.65; }
.service-row.is-selected .row-chevron { color: rgba(255, 255, 255, 0.85); opacity: 1; }

/* Apple Squircle Service Icons */
.record-icon {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 660;
  color: #ffffff;
  background: linear-gradient(155deg, #409cff, #007aff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.record-icon[data-tone="1"] { background: linear-gradient(155deg, #7d7aff, #5856d6); }
.record-icon[data-tone="2"] { background: linear-gradient(155deg, #46d8c5, #00a896); }
.record-icon[data-tone="3"] { background: linear-gradient(155deg, #52d972, #28b446); }
.record-icon[data-tone="4"] { background: linear-gradient(155deg, #ffb340, #ff8800); }
.record-icon[data-tone="5"] { background: linear-gradient(155deg, #ff6482, #e63956); }

.record-icon-letter {
  transition: opacity 0.18s var(--ease);
}
.record-favicon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 6px;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.record-icon.has-favicon {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), inset 0 0 0 0.5px rgba(0, 0, 0, 0.08);
}
.record-icon.has-favicon .record-icon-letter {
  opacity: 0;
}
.record-icon.has-favicon .record-favicon {
  opacity: 1;
}

.service-row.is-selected .record-icon {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 0 0 1.5px rgba(255, 255, 255, 0.35);
}
.service-row.is-selected .record-icon.has-favicon {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.record-icon-lg {
  width: 54px;
  height: 54px;
  border-radius: 15px;
  font-size: 23px;
  box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 0.34), 0 6px 16px rgba(0, 0, 0, 0.1);
}
.record-icon-lg .record-favicon {
  padding: 9px;
}
.record-icon-lg.has-favicon {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.09), inset 0 0 0 0.5px rgba(0, 0, 0, 0.08);
}

/* Detail Inspector Pane */
.detail-pane {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 36px clamp(24px, 4vw, 56px) 64px;
  background: var(--canvas);
}

.mobile-detail-bar {
  display: none;
  margin-bottom: 16px;
}
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px 6px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-size: 15px;
  font-weight: 560;
}
.back-button svg { width: 17px; height: 17px; }

.detail-card {
  max-width: 680px;
  margin-inline: auto;
  animation: detailFadeIn 0.2s var(--ease);
}
@keyframes detailFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.detail-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.detail-identity {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.detail-title-wrap { min-width: 0; }
.detail-title-wrap h2 {
  font-family: var(--font-display);
  font-size: clamp(22px, 2.6vw, 28px);
  font-weight: 700;
  letter-spacing: -0.028em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.detail-hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.meta-pill, .role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--input-bg);
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 550;
}
.meta-pill-accent, .role-badge {
  background: var(--accent-tint);
  color: var(--accent);
}
.meta-pill-status {
  background: var(--green-tint);
  color: var(--green);
}
.meta-pill-danger {
  background: var(--red-tint);
  color: var(--red);
}

/* Apple Grouped Inset Cards */
.inset-group, .panel {
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.inset-group:not(.inset-notes):not(:has(.credential-row)) {
  display: none;
}

.inset-section {
  margin-top: 22px;
}
.inset-section-label {
  margin: 0 0 8px 14px;
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.inset-notes {
  padding: 16px 20px;
}
.notes-value {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.credential-grid {
  display: grid;
}
.credential-row {
  display: grid;
  grid-template-columns: 144px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 11px 20px;
}
.credential-row + .credential-row {
  border-top: 1px solid var(--hairline);
}
.credential-row dt {
  color: var(--ink-secondary);
  font-size: 13.5px;
  font-weight: 500;
}
.credential-row dd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.credential-value {
  min-width: 0;
  flex: 1;
  font-size: 14.5px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
code.credential-value {
  font-family: var(--font-mono);
  font-size: 13.5px;
}
.code-terminal {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--input-bg);
}
.secret-value.is-masked {
  color: var(--ink-tertiary);
  letter-spacing: 0.12em;
  user-select: none;
}
.service-link {
  color: var(--accent);
  font-weight: 500;
}
.service-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.credential-actions, .actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 16px;
  padding-inline: 6px;
  color: var(--ink-tertiary);
  font-size: 12.5px;
}

.detail-placeholder {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  height: 100%;
  min-height: 300px;
  color: var(--ink-secondary);
  text-align: center;
}

/* Empty states & Notices */
.empty-state {
  display: grid;
  justify-items: center;
  align-content: center;
  text-align: center;
  gap: 8px;
  min-height: 240px;
  padding: 28px 20px;
}
.empty-state-compact { min-height: 200px; }
.empty-state h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.empty-state p { color: var(--ink-secondary); font-size: 14px; }
.empty-badge {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  border-radius: 14px;
  background: var(--input-bg);
  color: var(--ink-secondary);
}
.empty-badge svg { width: 22px; height: 22px; }

.notices { display: grid; gap: 8px; margin-bottom: 18px; }
.notice {
  padding: 11px 15px;
  border-radius: 12px;
  background: var(--green-tint);
  color: var(--green);
  font-size: 14px;
  font-weight: 520;
}
.notice-error {
  background: var(--red-tint);
  color: var(--red);
}

/* Floating macOS HUD Toast */
.toast {
  position: fixed;
  z-index: 50;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 14px);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-toast);
  font-size: 13.5px;
  font-weight: 540;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.24s var(--ease), visibility 0.2s;
}
.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* Auth screens (Apple iCloud / Passwords aesthetic) */
.auth-main {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(ellipse 65% 50% at 25% 15%, var(--auth-glow-1), transparent 70%),
    radial-gradient(ellipse 55% 45% at 80% 85%, var(--auth-glow-2), transparent 70%),
    var(--canvas);
}
.auth-card {
  width: min(100%, 400px);
  padding: clamp(26px, 5vw, 38px);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-auth);
}
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  margin-bottom: 24px;
}
.auth-brand-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.auth-brand-text small {
  display: block;
  margin-top: 2px;
  color: var(--ink-tertiary);
  font-size: 11px;
  font-weight: 640;
  letter-spacing: 0.09em;
}
.auth-heading {
  text-align: center;
  margin-bottom: 22px;
}
.auth-heading h1 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.auth-heading p {
  margin-top: 6px;
  color: var(--ink-secondary);
  font-size: 14px;
}
.auth-card .stack-form > .button {
  width: 100%;
  margin-top: 6px;
}
.auth-secondary {
  margin-top: 16px;
  text-align: center;
}
.auth-secondary .back-link { margin-bottom: 0; }

/* Forms & Editors */
.editor-panel {
  max-width: 760px;
  padding: clamp(20px, 3.5vw, 30px);
}
.editor-panel > h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 660;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}
.reset-hint {
  margin: -8px 0 18px;
  color: var(--ink-secondary);
  font-size: 14px;
}
.stack-form, .field, .field-group {
  display: grid;
  align-content: start;
  min-width: 0;
}
.stack-form { gap: 18px; }
.field, .field-group { gap: 6px; }
.field > span {
  font-size: 13px;
  font-weight: 580;
  color: var(--ink-secondary);
}
.field input,
.field textarea,
.field select,
.field-group input:not([type="checkbox"]),
.field-group textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: 10px;
  background: var(--surface-subtle);
  color: var(--ink);
  font-size: 15px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background-color 0.15s var(--ease);
}
.field input:focus,
.field textarea:focus,
.field select:focus,
.field-group input:not([type="checkbox"]):focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--input-focus-bg);
  box-shadow: 0 0 0 3.5px var(--accent-ring);
}
.field input:disabled,
.field-group input:disabled,
.field-group textarea:disabled {
  background: var(--input-bg);
  opacity: 0.6;
}
.field textarea, .field-group textarea { resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: var(--ink-tertiary); }
.field-hint {
  display: block;
  color: var(--ink-secondary);
  font-size: 12.5px;
}
.field-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

/* Apple Switch */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 13px;
  background: var(--surface-subtle);
  border: 1px solid var(--hairline);
  cursor: pointer;
}
.switch-copy strong { display: block; font-size: 14.5px; font-weight: 580; }
.switch-copy small { display: block; margin-top: 2px; color: var(--ink-secondary); font-size: 12.5px; }

.apple-switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: var(--input-bg);
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}
.apple-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s var(--ease);
}
.apple-switch:checked { background: var(--green-solid); }
.apple-switch:checked::after { transform: translateX(18px); }

/* Apple Segmented Control */
.segmented-control {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 3px;
  border-radius: 10px;
  background: var(--input-bg);
  width: fit-content;
  max-width: 100%;
}
.segmented-option {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.segmented-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented-option span {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 540;
  color: var(--ink-secondary);
  transition: background-color 0.16s var(--ease), color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.segmented-option input:checked + span {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 0 0.5px var(--hairline);
}

.form-section {
  display: grid;
  min-width: 0;
  gap: 12px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: var(--surface-subtle);
}
.form-section legend {
  padding-inline: 6px;
  font-size: 13.5px;
  font-weight: 640;
  color: var(--ink);
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 8px;
}
.checkbox-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 0.14s var(--ease), background-color 0.14s var(--ease);
}
.checkbox-pill:hover { border-color: var(--hairline-strong); }
.checkbox-pill input, .checkbox-label input {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-size: 13.5px;
  cursor: pointer;
}
.checkbox-danger { color: var(--red); }

.option-list { display: grid; gap: 6px; }
.override {
  border: 1px solid var(--hairline);
  border-radius: 11px;
  background: var(--surface);
  overflow: hidden;
}
.override summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 12px;
  list-style: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 560;
}
.override summary::-webkit-details-marker { display: none; }
.override summary::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-right: 1.6px solid var(--ink-tertiary);
  border-bottom: 1.6px solid var(--ink-tertiary);
  transform: rotate(-45deg);
  transition: transform 0.16s var(--ease);
}
.override[open] summary::before { transform: rotate(45deg); }
.override-marker {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
}
.override-body {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
  border-top: 1px solid var(--hairline);
  padding-top: 10px;
}

/* Users & History */
.user-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 20px;
}
.user-item + .user-item { border-top: 1px solid var(--hairline); }
.user-item-text { flex: 1; min-width: 0; }
.user-item-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.user-item h2 { font-size: 15.5px; font-weight: 620; }
.user-item p { margin-top: 2px; color: var(--ink-secondary); font-size: 13.5px; overflow-wrap: anywhere; }

.history-list { display: grid; gap: 14px; }
.history-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--hairline);
}
.history-entry-header h2 {
  font-size: 15.5px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}
.history-entry-header p { margin-top: 2px; color: var(--ink-secondary); font-size: 13px; }
.history-empty {
  padding: 14px 20px;
  color: var(--ink-secondary);
  font-size: 14px;
}

/* Audit log */
.audit-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.audit-filters .field { flex: 1 1 180px; max-width: 280px; }
.audit-filters .actions { margin-left: auto; }

.audit-table-wrap { overflow-x: auto; }
.audit-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}
.audit-table th, .audit-table td {
  padding: 12px 18px;
  vertical-align: middle;
}
.audit-table th {
  color: var(--ink-secondary);
  background: var(--surface-subtle);
  font-size: 12px;
  font-weight: 620;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--hairline);
}
.audit-table tbody tr + tr td { border-top: 1px solid var(--hairline); }
.audit-table tbody tr:hover td { background: var(--surface-hover); }
.audit-time {
  white-space: nowrap;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}
.actor-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 7px;
  background: var(--input-bg);
  font-weight: 560;
}
.action-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--input-bg);
  color: var(--ink);
}
.action-pill[data-action="Копирование"] { background: var(--green-tint); color: var(--green); }
.action-pill[data-action="Вход"] { background: var(--accent-tint); color: var(--accent); }
.action-pill[data-action="Выдача секрета"] { background: var(--amber-tint); color: var(--amber); }
.action-pill[data-action="Выход"] { background: var(--input-bg); color: var(--ink-secondary); }
.audit-target {
  display: inline-block;
  margin-left: 8px;
  color: var(--ink-secondary);
}

/* Responsive */
@media (max-width: 1080px) {
  .app { grid-template-columns: 214px minmax(0, 1fr); }
  .split-layout { grid-template-columns: 290px minmax(0, 1fr); }
  .credential-row { grid-template-columns: 118px minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .app { display: block; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--hairline);
  }
  .sidebar-top { padding: 0; }
  .sidebar-account {
    grid-area: 1 / 2;
    margin: 0;
    padding: 0;
    border: 0;
  }
  .account-meta { display: none; }
  .navigation, .categories {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 4px;
  }
  .categories h2 { display: none; }
  .nav-link, .category-button { flex: 0 0 auto; width: auto; }

  .main-workspace {
    height: auto;
    overflow: visible;
  }
  .split-layout {
    display: block;
    height: auto;
  }
  .list-pane {
    border-right: 0;
    min-height: calc(100vh - 150px);
  }
  .detail-pane {
    display: none;
    padding: 18px 16px 56px;
  }
  .split-layout.is-detail-open .list-pane { display: none; }
  .split-layout.is-detail-open .detail-pane { display: block; }
  .mobile-detail-bar { display: block; }

  .search-kbd { display: none; }
  .page-wrap { padding: 24px 16px 56px; }
  .credential-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    padding: 12px 16px;
  }
}

@media (max-width: 520px) {
  .field-pair { grid-template-columns: minmax(0, 1fr); }
  .audit-filters .field { max-width: none; }
  .audit-filters .actions { margin-left: 0; }
  .audit-table th, .audit-table td { padding: 10px 12px; }
  .audit-target { display: block; margin-left: 0; margin-top: 4px; }
}
