:root {
  color-scheme: light;
  --bg: #f7f9fb;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --selected: #e8f9fb;
  --selected-strong: #d8f4f7;
  --ink: #0f172a;
  --muted: #6b7280;
  --muted-soft: #94a3b8;
  --border: #dde5ec;
  --accent: #0e9aa7;
  --accent-dark: #0b7d88;
  --success: #16a34a;
  --shadow: 0 8px 24px rgb(15 23 42 / 0.05);
  --sidebar-width: 238px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #081316;
  --surface: #102027;
  --surface-soft: #162b33;
  --selected: #123a40;
  --selected-strong: #164850;
  --ink: #eef7f7;
  --muted: #afc0c6;
  --muted-soft: #8ea4ab;
  --border: #315057;
  --shadow: 0 14px 34px rgb(0 0 0 / 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body,
button,
input,
select,
textarea {
  font: 400 14px/1.35 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--ink);
  outline: 0;
}

textarea {
  min-height: 78px;
  resize: vertical;
}

h1,
h2,
h3,
p,
strong,
span {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  line-height: 1.25;
  font-weight: 650;
}

svg {
  display: block;
}

.app-shell {
  height: 100vh;
  min-height: 720px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  overflow: hidden;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 14px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 14px 12px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 8px 12px;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, #10a6b1, #0b7782);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12);
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.brand {
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.unlock-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: var(--surface);
}

.unlock-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.unlock-row div {
  display: grid;
  gap: 2px;
}

.unlock-row strong {
  color: var(--success);
  font-size: 15px;
  font-weight: 700;
}

.unlock-row span,
.nav-section,
.tool-row span,
.sidebar-footer span,
.muted,
.detail-subtitle,
.field span,
.list-meta,
.detail-meta,
.create-card p,
.create-card span {
  color: var(--muted);
  font-size: 12px;
}

.lock-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  background: #dcfce7;
  color: var(--success);
}

.lock-icon svg {
  width: 17px;
  height: 17px;
}

.nav-section {
  text-transform: uppercase;
  padding: 0 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.nav-list {
  display: grid;
  gap: 3px;
}

.nav-list button,
.tool-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 36px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 500;
  padding: 0 10px;
}

.nav-button-label,
.tool-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.nav-icon {
  display: inline-flex;
  width: 16px;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
}

.nav-list button.active,
.nav-list button:hover,
.placeholder-row:hover {
  background: var(--selected);
  color: var(--accent);
}

.nav-list button.active .nav-icon,
.nav-list button:hover .nav-icon,
.placeholder-row:hover .nav-icon,
.tool-row:hover .nav-icon {
  color: var(--accent);
}

.nav-list span:last-child {
  margin-left: auto;
  color: var(--accent);
  font-weight: 600;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

.tool-row span:last-child {
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--surface-soft);
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.sidebar-version-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.mini-icon-button,
.header-icon-button,
.star-button {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  width: 34px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}

.secondary-button,
.plain-button {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}

.plain-button:hover,
.secondary-button:hover,
.header-icon-button:hover,
.star-button:hover,
.mini-icon-button:hover {
  border-color: color-mix(in srgb, var(--border) 60%, var(--accent));
}

:root[data-session="connected"] #registerButton,
:root[data-session="connected"] #loginButton {
  display: none;
}

.workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  padding-bottom: 64px;
}

.server-bar {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 18px 0 20px;
}

.server-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.server-label {
  font-weight: 600;
}

.connected {
  padding: 3px 10px;
  border-radius: 999px;
  background: #dcfce7;
  color: #15803d;
  font-size: 12px;
  font-weight: 600;
}

.server-address-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 270px;
}

.server-address-wrap input {
  min-height: 30px;
  border: 0;
  background: transparent;
  padding: 0;
}

.topbar-spacer {
  flex: 1 1 auto;
}

.account-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 0 16px;
  border-left: 1px solid var(--border);
}

.account-icon,
.chevron {
  color: var(--muted);
}

.account-pill strong {
  font-weight: 650;
}

.sync-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sync-button {
  min-height: 34px;
}

.sync-status {
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.sync-status[data-tone="success"] {
  color: var(--success);
}

.sync-status[data-tone="warning"] {
  color: #c2410c;
}

.unlock-panel {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) repeat(3, minmax(180px, 240px)) auto;
  gap: 14px;
  align-items: end;
  margin: 20px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.unlock-copy {
  display: grid;
  gap: 8px;
}

.auth-actions {
  display: flex;
  gap: 8px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.vault-layout {
  height: calc(100vh - 48px - 64px);
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
}

.list-pane {
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--border);
  padding: 16px 12px 0;
  background: var(--bg);
}

.list-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px 38px;
  gap: 8px;
}

.search-field {
  position: relative;
  display: block;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 8px;
  color: var(--muted);
}

.search-field input {
  padding-left: 34px;
  padding-right: 58px;
}

.shortcut-badge {
  position: absolute;
  right: 10px;
  top: 8px;
  display: inline-flex;
  min-width: 28px;
  height: 20px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted-soft);
  font-size: 11px;
  font-weight: 600;
}

.square-button {
  width: 38px;
  padding: 0;
}

.list-meta {
  display: flex;
  justify-content: space-between;
  margin: 12px 6px 10px;
}

.items {
  display: grid;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  background: var(--surface);
  max-height: calc(100vh - 210px);
}

.item-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 64px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.item-row:last-child {
  border-bottom: 0;
}

.item-row.active,
.item-row:hover {
  background: var(--selected);
  border-left-color: var(--accent);
}

.item-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  overflow: hidden;
}

.item-icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.item-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.item-copy strong,
.item-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-copy strong {
  font-weight: 600;
}

.item-copy small,
.item-type,
.item-side small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.item-side {
  display: grid;
  justify-items: end;
  gap: 5px;
}

.item-side-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.item-type {
  padding: 3px 8px;
  border-radius: 6px;
  background: #eefafc;
  color: var(--accent);
  font-weight: 600;
}

.row-star {
  color: #fbbf24;
  font-size: 15px;
}

.end-note {
  padding: 16px 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.detail-workspace {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 16px 18px 18px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.item-header {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.item-avatar {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-weight: 800;
  font-size: 30px;
  overflow: hidden;
}

.item-avatar img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.item-heading-stack {
  display: grid;
  gap: 5px;
}

.item-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-subtitle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.more-button {
  min-width: 92px;
}

.star-button.active {
  color: #fbbf24;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) 350px;
  gap: 14px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 280px;
  gap: 14px;
}

.detail-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
}

.detail-body {
  display: grid;
  gap: 0;
  align-content: start;
  min-height: 332px;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-of-type {
  border-bottom: 0;
}

.detail-row span {
  grid-column: 1;
  color: var(--muted);
  font-size: 12px;
}

.detail-value {
  grid-column: 1;
  overflow-wrap: anywhere;
  font-weight: 500;
}

.password-value-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.password-text {
  letter-spacing: 0.15em;
}

.detail-icon-button {
  justify-self: end;
}

.detail-icon-button.eye {
  color: var(--muted);
}

.detail-meta {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.generator {
  display: grid;
  align-content: start;
  gap: 12px;
}

.strength-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.strength-row strong {
  color: var(--success);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.success-dot {
  background: #22c55e;
}

.strength-bars {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.strength-bars span {
  height: 4px;
  border-radius: 999px;
  background: #22c55e;
}

.inline-input-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px 38px;
  gap: 8px;
  align-items: center;
}

.inline-input-group input {
  min-height: 38px;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.field-inline-range {
  gap: 8px;
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px;
  gap: 10px;
  align-items: center;
}

#passwordLength {
  accent-color: var(--accent);
  min-height: auto;
}

#passwordLengthValue {
  min-height: 34px;
}

.toggle-row {
  display: grid;
  gap: 10px;
}

.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #d7e3ea;
  transition: background-color 0.15s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.18);
  transition: transform 0.15s ease;
}

.switch-row input:checked + .switch {
  background: var(--accent);
}

.switch-row input:checked + .switch::after {
  transform: translateX(14px);
}

.generator-button {
  width: 100%;
}

.editor-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  align-content: start;
}

.editor-panel h2,
.type-tabs,
.type-fields,
.button-row {
  grid-column: 1 / -1;
}

.editor-panel input,
.editor-panel select,
.editor-panel textarea {
  min-height: 34px;
  padding: 7px 9px;
}

.editor-panel textarea {
  min-height: 74px;
}

.type-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.type-tabs button {
  min-height: 34px;
  border-radius: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.type-tabs button:last-child {
  border-right: 0;
}

.type-tabs button.active {
  background: var(--selected);
  color: var(--accent);
}

.type-select,
.tags-field {
  display: none;
}

.type-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}

.type-fields .wide {
  grid-column: 1 / -1;
}

.password-field {
  position: relative;
}

.password-inline-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px 34px auto;
  gap: 6px;
  align-items: center;
}

.password-inline-actions button {
  width: 34px;
  min-height: 34px;
  padding: 0;
}

.generate-inline-button {
  min-width: 84px;
  padding: 0 10px !important;
}

.button-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.create-card {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 10px;
  align-content: center;
}

.create-icon {
  font-size: 58px;
  color: var(--muted-soft);
}

#createCardTitle {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.health-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 64px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 18px;
  align-items: center;
}

.health-strip div {
  display: grid;
  gap: 3px;
  padding-left: 34px;
  position: relative;
}

.health-strip div::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 1px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  background: #dcfce7;
  color: var(--success);
  font-weight: 800;
  font-size: 12px;
}

.health-strip span {
  color: var(--muted);
  font-size: 12px;
}

.health-action {
  min-width: 110px;
  justify-self: end;
}

.empty-state {
  display: grid;
  place-content: center;
  min-height: 250px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  margin-bottom: 6px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1320px) {
  .detail-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .vault-layout,
  .unlock-panel {
    grid-template-columns: 1fr;
  }

  .server-bar {
    flex-wrap: wrap;
    padding: 12px 18px;
  }

  .server-address-wrap,
  .sync-cluster {
    min-width: 100%;
  }

  .health-strip {
    grid-template-columns: 1fr 1fr;
    height: auto;
    padding-bottom: 16px;
  }

  .workspace {
    padding-bottom: 108px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .item-header,
  .editor-panel,
  .type-fields,
  .health-strip {
    grid-template-columns: 1fr;
  }

  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .detail-workspace {
    padding: 16px;
  }

  .list-pane {
    border-right: 0;
  }

  .workspace {
    padding-bottom: 0;
  }

  .health-strip {
    position: static;
  }
}
