@font-face {
  font-family: "JetBrains Mono Embedded";
  src: url("/static/fonts/jetbrains-mono/jetbrains-mono-regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono Embedded";
  src: url("/static/fonts/jetbrains-mono/jetbrains-mono-italic.woff2") format("woff2");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono Embedded";
  src: url("/static/fonts/jetbrains-mono/jetbrains-mono-medium.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono Embedded";
  src: url("/static/fonts/jetbrains-mono/jetbrains-mono-bold.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #142033;
  --muted: #5a6472;
  --line: #d8dfec;
  --accent: #0b5ed7;
  --danger: #b02a37;
  --ok: #198754;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "JetBrains Mono Embedded", "JetBrains Mono", "IBM Plex Sans", "Avenir Next", "Segoe UI", monospace;
  color: var(--text);
  background: radial-gradient(circle at top left, #eef4ff 0, #f4f6fb 45%, #eef2fb 100%);
}

.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.shell.narrow {
  max-width: 700px;
}

.shell-header {
  margin-bottom: 1rem;
}

.shell-header h1 {
  margin: 0;
  font-size: 1.75rem;
}

.shell-header p {
  margin: 0.3rem 0 0;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 6px 24px rgba(21, 30, 60, 0.06);
}

.hidden {
  display: none !important;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
}

.grid-2.compact {
  margin: 1rem 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
  color: #2d3a51;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.65rem;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
  width: 100%;
}

.btn {
  border: 1px solid #aebad0;
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  background: #f5f7fc;
  color: #1f2d46;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(0.98);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn.danger {
  background: #fff1f2;
  color: var(--danger);
  border-color: #f0bbc1;
}

.auth-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.auth-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.auth-card h3 {
  margin: 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.vault-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  flex-wrap: wrap;
  min-height: 132px;
  align-content: space-between;
}

.utility-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1rem;
}

.utility-vault {
  grid-column: 1;
}

.utility-diceware {
  grid-column: 2;
}

.main-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
}

.panel h2,
.panel h3 {
  margin-top: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.note-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: stretch;
}

.note-editor textarea {
  min-height: 360px;
}

.note-tools {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.note-tools .btn {
  min-width: 88px;
}

.diceware-card {
  display: grid;
  gap: 0.75rem;
  align-content: start;
  min-height: 132px;
}

.diceware-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.dice-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(180deg, #f8fbff 0%, #e7eefc 100%);
}

.dice-pips {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  box-shadow:
    -10px -10px 0 currentColor,
    10px -10px 0 currentColor,
    -10px 10px 0 currentColor,
    10px 10px 0 currentColor;
}

.diceware-output {
  width: 100%;
  text-align: center;
  cursor: text;
  user-select: all;
  font-size: 0.92rem;
}

.admin-tools {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.drop-zone {
  border: 2px dashed #8ba3cc;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  background: #f8fbff;
  margin-bottom: 0.5rem;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: #e8f1ff;
}

.checkbox-row {
  flex-direction: row;
  align-items: center;
  margin-top: 1.45rem;
}

.status {
  color: var(--muted);
  margin: 0.4rem 0;
}

.status.ok {
  color: var(--ok);
}

.status.error {
  color: var(--danger);
}

.status.global {
  min-height: 1.2em;
}

.upload-table,
.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.upload-table th,
.upload-table td,
.audit-table th,
.audit-table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 0.5rem 0.35rem;
  vertical-align: top;
}

.upload-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.4rem;
}

.history-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.history-list li:hover {
  background: #f8fbff;
}

.note-history-item {
  position: relative;
  padding-right: 1.7rem;
}

.snippet-delete {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  padding: 0.2rem;
}

.note-history-item:hover .snippet-delete,
.note-history-item:focus-within .snippet-delete {
  opacity: 1;
  pointer-events: auto;
}

.history-preview {
  display: block;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qr-wrap {
  margin-top: 1rem;
  display: grid;
  gap: 0.7rem;
  max-width: 280px;
}

.qr-wrap img {
  width: 220px;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

@media (max-width: 820px) {
  .utility-grid {
    grid-template-columns: 1fr;
  }

  .utility-vault,
  .utility-diceware {
    grid-column: auto;
  }

  .vault-row {
    align-items: stretch;
  }

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

  .note-editor {
    grid-template-columns: 1fr;
  }

  .note-tools {
    flex-direction: row;
    flex-wrap: wrap;
  }
}
