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

:root {
  --bg: var(--platform-bg, #e7e9e4);
  --surface: #1a1d27;
  --surface-2: #242836;
  --border: #2e3345;
  --text: #e8eaef;
  --text-muted: #8b92a5;
  --accent: #6c8cff;
  --accent-hover: #5578f5;
  --success: #34d399;
  --error: #f87171;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --pdf-sidebar-w: 15.5rem;
}

body {
  font-family: var(--platform-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.pdf-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "intro"
    "search"
    "main"
    "nav";
  max-width: var(--platform-content-max, 72rem);
  margin: 0 auto;
  min-height: calc(100vh - var(--platform-topbar-h, 3rem));
  padding-bottom: 2rem;
  align-items: start;
}

.pdf-sidebar {
  display: none;
}

.pdf-sidebar__intro {
  grid-area: intro;
}

.pdf-sidebar__intro h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.03em;
}

.pdf-sidebar__intro p {
  margin: 0;
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.platform-tool-search-wrap {
  grid-area: search;
}

.pdf-tool-search {
  width: 100%;
}

.tool-nav.platform-tool-grid {
  grid-area: nav;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: 0.75rem;
  margin: 0 1.25rem 1.5rem;
}

.tool-nav__group {
  grid-column: 1 / -1;
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}

.tool-nav__group:first-child {
  margin-top: 0;
}

.tool-tab.platform-tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  text-align: left;
  min-height: 5.5rem;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.tool-tab.platform-tool-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  transform: translateY(-2px);
}

.tool-tab.platform-tool-card.active {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--accent);
}

.tool-tab .platform-tool-card__title {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
}

.tool-tab .platform-tool-card__desc {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.tool-tab.is-hidden,
.tool-nav__group.is-hidden,
.is-search-hidden {
  display: none !important;
}

.pdf-main {
  grid-area: main;
  max-width: 40rem;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.25rem 1.5rem;
  scroll-margin-top: calc(var(--platform-topbar-h, 3rem) + 0.75rem);
}

@media (min-width: 960px) {
  .pdf-layout {
    grid-template-columns: var(--pdf-sidebar-w) minmax(0, 1fr);
    grid-template-areas:
      "intro intro"
      "search search"
      "nav main";
    column-gap: 1.5rem;
  }

  .tool-nav.platform-tool-grid {
    grid-template-columns: 1fr;
    gap: 0.45rem;
    margin: 0;
    position: sticky;
    top: calc(var(--platform-topbar-h, 3rem) + 0.75rem);
    max-height: calc(100vh - var(--platform-topbar-h, 3rem) - 1.5rem);
    overflow: auto;
    padding-right: 0.25rem;
  }

  .tool-nav__group {
    margin-top: 0.75rem;
  }

  .tool-tab.platform-tool-card {
    min-height: 0;
    padding: 0.65rem 0.75rem;
  }

  .tool-tab .platform-tool-card__desc {
    font-size: 0.75rem;
  }

  .pdf-main {
    max-width: 42rem;
    margin: 0;
    padding: 0 0 3rem;
  }
}

header {
  display: none;
}

main {
  max-width: none;
  margin: 0;
  padding: 0;
}

.tool-panel {
  display: none;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.tool-panel.active {
  display: block;
}

.tool-panel h2 {
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
}

.desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.55;
}

.app-help {
  margin-bottom: 1.25rem;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.app-help .help-tips {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
}

.app-help .help-tips summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.app-help ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}

.app-help li {
  margin-bottom: 0.3rem;
  line-height: 1.45;
}

.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 1.75rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 1rem;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(108, 140, 255, 0.06);
}

.drop-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.5rem;
}

.drop-zone p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

.hint {
  font-size: 0.8rem !important;
  margin-top: 0.25rem;
}

.file-list {
  list-style: none;
  margin-bottom: 1rem;
}

.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
}

.file-list .remove-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 0.25rem;
  line-height: 1;
}

.file-list .remove-btn:hover {
  color: var(--error);
}

.field {
  margin-bottom: 1rem;
}

.field-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.field-row .field {
  flex: 1;
  margin-bottom: 0;
}

.field.flex-2 {
  flex: 2;
}

.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  font-weight: 500;
}

.field input,
.field select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.5rem;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  min-height: 2.75rem;
  position: sticky;
  bottom: 0.75rem;
  z-index: 2;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.secondary:hover:not(:disabled) {
  border-color: var(--accent);
}

.password-field {
  border-left: 3px solid var(--accent);
  padding-left: 0.85rem;
  background: rgba(108, 140, 255, 0.04);
  border-radius: 0 8px 8px 0;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 1rem;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.modal-card h3 {
  margin-bottom: 0.35rem;
}

.modal-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.modal-actions .btn {
  flex: 1;
}

.info-result {
  margin-top: 1.25rem;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 1.25rem;
  font-size: 0.875rem;
}

.info-result dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
}

.info-result dt {
  color: var(--text-muted);
  font-weight: 500;
}

.info-result dd {
  word-break: break-all;
}

.info-result table {
  width: 100%;
  margin-top: 1rem;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.info-result th,
.info-result td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.info-result th {
  color: var(--text-muted);
  font-weight: 500;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: 90vw;
}

.toast.error {
  border-color: var(--error);
  color: var(--error);
}

.toast.success {
  border-color: var(--success);
  color: var(--success);
}

.loading {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 23, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  gap: 1rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 520px) {
  .field-row {
    flex-direction: column;
  }

  .pdf-main {
    padding: 1.15rem 1rem 2.5rem;
  }

  .tool-nav.platform-tool-grid {
    margin-left: 1rem;
    margin-right: 1rem;
  }
}
