@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --bg: #f8f9fb;
  --panel: #ffffff;
  --panel-2: #eef1f6;
  --flash: #4a5568;
  --flash-success: #4a5568;
  --flash-text: #f9f9f9;
  --flash-border: rgba(255, 255, 255, 0.18);
  --accent: #0a84ff;
  --accent-2: #0a84ff;
  --muted: #4b5563;
  --text: #0f1115;
  --danger: #d53f3f;
  --success: #198754;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --panel: #181b23;
  --panel-2: #1f2430;
  --flash: #2f3847;
  --flash-success: #2f3847;
  --flash-text: #ffffff;
  --flash-border: rgba(255, 255, 255, 0.2);
  --accent: #4f9dff;
  --accent-2: #9fc5ff;
  --muted: #c0c4ce;
  --text: #e8ecf4;
  --danger: #ef5350;
  --success: #66bb6a;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

header {
  background: var(--panel);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.title-btn {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  font-size: 15px;
  height: 36px;
  padding: 0 12px;
}

main {
  padding: 18px 14px 40px;
  width: min(960px, 100%);
  margin: 0 auto;
}

header .btn,
header .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 10px 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  gap: 6px;
}

.theme-toggle-btn {
  font-size: 15px;
  letter-spacing: 0.02em;
}

.header-nav {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Accordion styling (Settings) */
.accordion details {
  margin-bottom: 12px;
  border-radius: 12px;
  border: 1px solid var(--flash-border);
  background: var(--panel);
}
.accordion summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  background: var(--panel-2);
  border-radius: 12px;
  border: 1px solid var(--flash-border);
}
.accordion summary::-webkit-details-marker {
  display: none;
}
.accordion summary::before {
  content: '▸';
  font-size: 12px;
}
.accordion details[open] summary::before {
  content: '▾';
}
.accordion details[open] summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.accordion details > .card {
  margin: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: none;
}

.card {
  background: var(--panel);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.card-link:hover {
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.08);
}

input,
select,
textarea,
button {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid #d0d0d0;
  background: var(--panel);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="file"] {
  background: var(--panel);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.12);
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  color: var(--muted);
}

button,
.btn {
  cursor: pointer;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #ffffff;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  border-radius: 10px;
  padding: 10px 14px;
  width: auto;
}

button:hover,
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.btn-danger {
  background: var(--panel);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-ghost {
  background: var(--panel);
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: var(--text);
}

.flex {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px 12px;
}

.full-row {
  grid-column: 1 / -1;
}

.pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 20px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
  margin-right: 6px;
}

.tag-danger {
  background: #555;
  color: #fff;
}

.tag-success {
  background: #555;
  color: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel-2);
  border-radius: 12px;
}

th {
  background: var(--panel-2);
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 12px;
}

.flash {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--flash);
  color: var(--flash-text);
  border: 1px solid var(--flash-border);
}

.flash.error {
  background: #fff1f1;
  border-color: var(--danger);
}

.flash.success {
  background: var(--flash-success);
  border-color: var(--flash-border);
  color: var(--flash-text);
}

.alphabet {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.alphabet a {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.alphabet .active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.catalog-card {
  position: relative;
  overflow: hidden;
}

.catalog-card .meta {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
}

.catalog-card .badge {
  position: absolute;
  top: 12px;
  right: 12px;
}

.catalog-card .count {
  font-weight: 700;
  color: var(--muted);
}

.lemma-card {
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.2s ease, transform 0.1s ease;
  position: relative;
  background: linear-gradient(145deg, var(--panel) 0%, var(--panel-2) 100%);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.12);
}

.lemma-card:hover {
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

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

.edit-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--panel-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  border: 1px solid rgba(0, 0, 0, 0.18);
}

.lemma-details {
  margin-top: 8px;
  color: var(--text);
  display: none;
}

.lemma-card.open .lemma-details {
  display: block;
}

.lemma-meta {
  color: var(--muted);
  font-size: 13px;
}

.lemma-actions-top,
.lemma-actions-bottom {
  display: flex;
  gap: 6px;
}

.lemma-actions-top {
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
}

.lemma-actions-left,
.lemma-actions-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.lemma-card.active {
  border-color: var(--accent);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.14);
}

.lemma-expanded {
  margin-top: 12px;
  grid-column: 1 / -1;
}

.expanded-card {
  width: 100%;
}

.lemma-actions-bottom {
  justify-content: flex-end;
  margin-top: 8px;
}

.copy-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid rgba(0, 0, 0, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.attachment-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0 0;
}

.attachment-list li {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 6px 8px;
  border-radius: 8px;
  margin-bottom: 6px;
}

.tag-small {
  font-size: 12px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.overlay.show {
  display: flex;
}

.overlay-content {
  background: var(--panel);
  color: var(--text);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.overlay-close {
  float: right;
  border: 1px solid #d0d0d0;
  background: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  width: auto;
  color: #000;
}

.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.hidden {
  display: none !important;
}

.workspace-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}


.popup {
  background: var(--panel);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: var(--shadow);
  border-radius: 14px;
  padding: 18px;
  max-width: 640px;
}

.popup h3 {
  margin-top: 0;
}

.small-text {
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 640px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .header-nav {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .lemma-actions-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .lemma-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}
