:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --ink: #172033;
  --muted: #657086;
  --line: #d9dfeb;
  --panel: #ffffff;
  --blue: #1769e0;
  --green: #18a058;
  --red: #dc3d43;
  --shadow: 0 16px 42px rgba(23, 32, 51, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(245, 247, 251, 0.9)),
    radial-gradient(circle at top left, rgba(23, 105, 224, 0.12), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: #aab5c8;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1.05;
  letter-spacing: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 112px;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.76);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
}

.status.connected .dot {
  background: var(--green);
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.side {
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel,
.editor-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

label,
.share-head,
.stats span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 8px 0;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
}

#roomInput {
  text-transform: uppercase;
}

.primary {
  width: 100%;
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}

.share {
  display: grid;
  gap: 12px;
}

.share-head,
.toolbar,
.stats > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.icon-btn {
  width: 38px;
  min-height: 34px;
  padding: 0;
}

#qrImage {
  width: 168px;
  height: 168px;
  place-self: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
  display: none;
}

.share-link {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.access {
  display: grid;
  gap: 8px;
}

.access-link {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--blue);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.45;
}

.access-tip {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.stats {
  gap: 10px;
}

.stats > div {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.stats > div:last-child {
  border-bottom: 0;
}

.stats strong {
  font-size: 16px;
}

.editor-panel {
  min-height: 650px;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.toolbar {
  min-height: 58px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.room-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  background: #eef4ff;
  color: #164f9e;
  font-size: 13px;
  font-weight: 750;
}

.tool-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

textarea {
  width: 100%;
  resize: none;
  outline: 0;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  line-height: 1.7;
}

textarea:disabled,
input:disabled {
  color: #9099aa;
}

.transfer-body {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.account-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.55fr) minmax(0, 1.9fr);
  gap: 12px;
}

.field-card,
.note-area {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.field-card {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.copy-field {
  min-height: 32px;
  padding: 0 11px;
  font-size: 13px;
}

.compact {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcff;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.id-card {
  align-content: start;
}

.id-list {
  display: grid;
  gap: 10px;
}

.bulk-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f7faff;
}

.bulk-box textarea {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  font-size: 13px;
  line-height: 1.45;
}

.bulk-actions {
  display: flex;
  gap: 8px;
}

.bulk-actions .primary {
  width: auto;
}

.id-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcff;
}

.id-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.id-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

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

.tk-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mini-field {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mini-field input {
  min-height: 38px;
  font-size: 13px;
  background: #fff;
}

.id-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.id-meta span {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  background: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.id-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.id-actions button {
  min-height: 36px;
  padding: 0 8px;
  font-size: 13px;
  white-space: nowrap;
}

.remove-id {
  color: var(--red);
}

.note-area {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  padding: 12px;
}

.notes {
  min-height: 320px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcff;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  max-width: min(520px, calc(100vw - 32px));
  border-radius: 8px;
  background: #172033;
  color: #fff;
  padding: 10px 14px;
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 840px) {
  input,
  textarea {
    font-size: 16px;
  }

  .shell {
    width: min(100vw - 20px, 720px);
    padding: 18px 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .side {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    min-height: 56vh;
  }

  .account-grid {
    grid-template-columns: 1fr;
  }

  .id-item {
    grid-template-columns: 1fr;
  }

  .id-fields {
    grid-template-columns: 1fr;
  }

  .tk-fields {
    grid-template-columns: 1fr;
  }

  .id-actions {
    flex-wrap: wrap;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .tool-actions {
    justify-content: stretch;
  }

  .tool-actions button {
    flex: 1;
  }
}
