:root {
  --ink: #17202a;
  --muted: #667085;
  --paper: #f7f7f2;
  --surface: #ffffff;
  --line: #dde3ea;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --gold: #c28b18;
  --blue: #2563eb;
  --red: #b42318;
  --shadow: 0 18px 50px rgba(23, 32, 42, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 56px);
  color: #fff;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.94), rgba(23, 32, 42, 0.96)),
    url("https://images.unsplash.com/photo-1513258496099-48168024aec0?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.eyebrow {
  margin: 0 0 6px;
  color: #d8efe9;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
  letter-spacing: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-heading h2,
.section-heading p {
  margin-bottom: 0;
}

.subject-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.section-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.install-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  font-weight: 800;
}

.install-button:hover {
  background: rgba(255, 255, 255, 0.26);
}

.install-button[hidden] {
  display: none;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.24);
}

main {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.subject-band {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(23, 32, 42, 0.08);
}

.subject-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.subject-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid #cfd7df;
  border-radius: 8px;
  padding: 9px 13px;
  color: #344054;
  background: #fff;
  font-weight: 800;
}

.subject-pill:hover {
  border-color: var(--teal);
  background: #f4fbf9;
}

.subject-pill.active {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
}

.subject-pill.active svg {
  color: #fff;
}

.stats-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats-band article {
  min-height: 92px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stats-band span {
  display: block;
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 850;
  line-height: 1;
}

.stats-band p {
  margin: 8px 0 0;
  color: var(--muted);
}

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

.upload-panel,
.library-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.upload-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title h2 {
  margin-bottom: 0;
}

.panel-title svg,
.drop-zone svg,
.empty-state svg {
  color: var(--teal);
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 172px;
  padding: 22px 16px;
  border: 2px dashed #9db5b1;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: #f4fbf9;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.drop-zone strong {
  color: var(--ink);
}

.drop-zone.drag-over {
  border-color: var(--teal);
  background: #e7f6f2;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.selected-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}

.file-chip,
.tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #1f2937;
  background: #edf2f7;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 0.86rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd7df;
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.15);
  border-color: var(--teal);
}

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

.subject-add-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  border: 1px solid #b8cbc7;
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--teal-dark);
  background: #f4fbf9;
  font-weight: 800;
  white-space: nowrap;
}

.subject-add-button:hover {
  border-color: var(--teal);
  background: #e7f6f2;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid #b8cbc7;
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--teal-dark);
  background: #f4fbf9;
  font-weight: 800;
  white-space: nowrap;
}

.secondary-button:hover {
  border-color: var(--teal);
  background: #e7f6f2;
}

.danger-lite-button {
  border-color: #f2c6c0;
  color: var(--red);
  background: #fff7f6;
}

.danger-lite-button:hover {
  border-color: var(--red);
  background: #fff0ee;
}

.primary-button,
.danger-button,
.text-button,
.dialog-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--teal);
}

.primary-button:hover {
  background: var(--teal-dark);
}

.library-panel {
  min-height: 560px;
  padding: 18px;
}

.library-title {
  margin-bottom: 14px;
}

.library-toolbar {
  display: grid;
  grid-template-columns: minmax(210px, 1.5fr) minmax(150px, 0.85fr) minmax(130px, 0.75fr) minmax(130px, 0.75fr);
  gap: 10px;
  margin-bottom: 16px;
}

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

.search-box svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search-box input {
  padding-left: 38px;
}

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

.document-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.document-accent {
  height: 8px;
  background: var(--teal);
}

.document-card[data-kind="pdf"] .document-accent {
  background: var(--red);
}

.document-card[data-kind="image"] .document-accent {
  background: var(--blue);
}

.document-card[data-kind="office"] .document-accent {
  background: var(--gold);
}

.document-body {
  padding: 14px;
}

.document-title-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.doc-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: var(--teal-dark);
  background: #e7f6f2;
}

.document-card[data-kind="pdf"] .doc-icon {
  color: var(--red);
  background: #fff0ee;
}

.document-card[data-kind="image"] .doc-icon {
  color: var(--blue);
  background: #eef4ff;
}

.document-card[data-kind="office"] .doc-icon {
  color: #8a5b05;
  background: #fff7df;
}

.document-title {
  min-width: 0;
}

.document-title h3 {
  margin: 0 0 5px;
  font-size: 1rem;
  line-height: 1.25;
  word-break: break-word;
}

.document-title p,
.doc-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0;
}

.doc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}

.doc-note {
  margin: 10px 0 0;
  color: #475467;
  font-size: 0.86rem;
  line-height: 1.45;
  word-break: break-word;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
}

.card-actions button {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.card-actions button:last-child {
  border-right: 0;
}

.card-actions button:hover {
  background: #f3f7f8;
}

.card-actions .delete-action:hover {
  color: var(--red);
  background: #fff0ee;
}

.empty-state {
  display: none;
  place-items: center;
  min-height: 420px;
  color: var(--muted);
  text-align: center;
}

.empty-state.visible {
  display: grid;
}

.empty-state h2 {
  margin: 10px 0 6px;
  color: var(--ink);
}

dialog {
  max-width: min(420px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(23, 32, 42, 0.46);
}

.dialog-card {
  display: grid;
  gap: 12px;
  padding: 22px;
}

.dialog-card svg {
  color: var(--red);
}

.dialog-card h2 {
  margin-bottom: 0;
}

.dialog-card p {
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-actions button {
  border: 1px solid var(--line);
  background: #fff;
}

.danger-button {
  color: #fff;
  background: var(--red) !important;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  transform: translateY(16px);
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

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

  .library-toolbar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .app-header {
    align-items: flex-start;
    padding: 24px 18px;
  }

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

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

  .secondary-button {
    width: 100%;
  }

  .subject-actions {
    width: 100%;
  }

  .subject-pills {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .subject-pill {
    width: 100%;
    min-width: 0;
  }

  .stats-band,
  .form-grid,
  .library-toolbar {
    grid-template-columns: 1fr;
  }

  .subject-control {
    grid-template-columns: 1fr;
  }

  main {
    width: min(100% - 20px, 1240px);
    padding-top: 12px;
  }
}
