:root {
  --bg: #f6f5f1;
  --bg-2: #efede7;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-strong: rgba(255, 255, 255, 0.9);
  --border: rgba(15, 15, 15, 0.08);
  --text: #111111;
  --muted: #6e6e73;
  --accent: #111111;
  --danger: #b42318;
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --shadow: 0 16px 50px rgba(0, 0, 0, 0.06);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.04);
  --max: 1240px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", sans-serif;
}

body[data-theme="dark"] {
  --bg: #0e0e10;
  --bg-2: #17171a;
  --panel: rgba(28, 28, 30, 0.72);
  --panel-strong: rgba(36, 36, 39, 0.92);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f5f5f7;
  --muted: #a1a1aa;
  --accent: #f5f5f7;
  --danger: #ff6b5e;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  font-family: var(--font);
}

body {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.shell {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
}

.screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card,
.panel,
.summary-strip,
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.login-card {
  width: 100%;
  max-width: 430px;
  border-radius: var(--radius-xl);
  padding: 36px;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.topbar {
  padding: 42px 0 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.topbar-main h1,
.login-card h1,
.panel h2,
.category-title,
.modal-card h3 {
  margin: 0;
  letter-spacing: -0.04em;
}

.topbar-main h1 {
  font-size: clamp(34px, 5vw, 54px);
  line-height: 0.96;
  font-weight: 700;
}

.topbar-subtle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.topbar-actions,
.panel-head-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow,
.panel-kicker,
.summary-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.eyebrow,
.panel-kicker {
  margin-bottom: 8px;
}

.subtle {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.summary-strip {
  border-radius: 22px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.summary-item {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-soft);
}

.summary-item strong {
  font-size: 24px;
  letter-spacing: -0.03em;
}

.dashboard {
  padding-bottom: 42px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  border-radius: var(--radius-xl);
  padding: 22px;
}

.hero-panel {
  padding-top: 24px;
}

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

.panel h2 {
  font-size: 30px;
  line-height: 1;
  font-weight: 650;
}

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

.add-form {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel-strong);
}

.add-form:not(.compact) {
  grid-template-columns: 1fr 1.2fr 1.1fr 0.9fr auto;
}

.add-form.compact {
  grid-template-columns: 1fr auto;
}

input,
textarea,
button,
a {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.66);
  color: var(--text);
  border-radius: 16px;
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

body[data-theme="dark"] input,
body[data-theme="dark"] textarea {
  background: rgba(255, 255, 255, 0.04);
}

input:focus,
textarea:focus {
  border-color: rgba(127, 127, 127, 0.32);
  box-shadow: 0 0 0 4px rgba(127, 127, 127, 0.08);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

textarea {
  resize: vertical;
  min-height: 400px;
  line-height: 1.58;
}

button {
  border: none;
  border-radius: 16px;
  padding: 12px 18px;
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
  opacity: 0.95;
}

button.ghost {
  background: rgba(127, 127, 127, 0.12);
  color: var(--text);
}

button.danger {
  color: var(--danger);
}

button.icon-only {
  padding: 10px 14px;
}

.error {
  color: var(--danger);
  min-height: 20px;
  margin-top: 12px;
}

.category-group + .category-group {
  margin-top: 28px;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 2px;
}

.category-title {
  font-size: 18px;
  font-weight: 650;
}

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

.link-card {
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 14px;
  background: var(--panel-strong);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: start;
  box-shadow: var(--shadow-soft);
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.link-card:hover {
  transform: translateY(-2px);
}

.link-icon {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  object-fit: cover;
  background: rgba(127, 127, 127, 0.12);
}

.link-main {
  min-width: 0;
}

.link-title {
  display: inline-block;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.25;
  color: var(--text);
}

.link-url {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
  word-break: break-all;
}

.link-actions {
  display: none;
  flex-direction: column;
  gap: 6px;
}

body.edit-mode .link-actions {
  display: flex;
}

body.edit-mode .link-card {
  outline: 2px dashed rgba(127, 127, 127, 0.25);
  background: rgba(127, 127, 127, 0.06);
  cursor: grab;
}

body.edit-mode .link-card:active {
  cursor: grabbing;
}

body.edit-mode .link-card:hover {
  transform: scale(1.02);
}

.icon-btn {
  background: rgba(127, 127, 127, 0.12);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 12px;
  min-width: 38px;
}

.todo-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.todo-item:last-child {
  border-bottom: none;
}

.todo-item.done .text {
  text-decoration: line-through;
  color: var(--muted);
}

.todo-item .text {
  line-height: 1.4;
}

.todo-item .delete {
  margin-left: auto;
  background: transparent;
  color: var(--muted);
  padding: 6px 8px;
}

.note-area {
  min-height: 400px;
}

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

.file-row {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--panel-strong);
  box-shadow: var(--shadow-soft);
}

.file-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

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

.file-actions a {
  text-decoration: none;
}

.search-input {
  max-width: 240px;
}

.progress-wrap {
  margin-bottom: 14px;
}

.progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(127, 127, 127, 0.12);
  margin-bottom: 8px;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.2s ease;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 18px;
  padding: 18px;
  color: var(--muted);
  background: rgba(127, 127, 127, 0.04);
  text-align: center;
  margin-top: 10px;
}

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
}

.modal-card {
  position: relative;
  width: min(620px, calc(100% - 24px));
  margin: 6vh auto 0;
  border-radius: 28px;
  padding: 22px;
  z-index: 1;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-form {
  display: grid;
  gap: 14px;
}

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

.field label {
  font-size: 13px;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.modal-actions-right {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 980px) {
  .add-form:not(.compact) {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 860px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  .add-form:not(.compact),
  .add-form.compact,
  .files-head-actions {
    grid-template-columns: 1fr;
    display: grid;
  }

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

  .file-row {
    grid-template-columns: 1fr;
  }

  .search-input {
    max-width: none;
  }

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

  .modal-actions-right {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
