:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d8dee9;
  --accent: #1c7c7d;
  --accent-strong: #135f60;
  --soft: #e9f5f4;
  --code-bg: #101828;
  --code-ink: #f7fafc;
}

* {
  box-sizing: border-box;
}

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

button,
input,
label {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.reader-panel {
  min-height: calc(100vh - 56px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(23, 32, 51, 0.08);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 2rem);
  line-height: 1.1;
}

#fileInput {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.file-button:hover {
  background: var(--accent-strong);
}

.file-icon {
  position: relative;
  width: 15px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.file-icon::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 6px;
  height: 6px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  background: var(--accent);
}

.file-button:hover .file-icon::after {
  background: var(--accent-strong);
}

.drop-zone {
  margin: 24px;
  min-height: 132px;
  display: grid;
  place-items: center;
  border: 2px dashed #9bb7b6;
  border-radius: 8px;
  background: var(--soft);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
  outline: none;
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: #dff1ef;
  transform: translateY(-1px);
}

.drop-zone:focus-visible {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 4px rgba(28, 124, 125, 0.18);
}

.drop-copy {
  display: grid;
  gap: 6px;
  text-align: center;
  padding: 22px;
}

.drop-copy strong {
  font-size: 1.05rem;
}

.drop-copy span,
.file-meta {
  color: var(--muted);
}

.document-area {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  border-top: 1px solid var(--line);
}

.file-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.file-meta span:first-child {
  color: var(--ink);
  font-weight: 700;
}

.markdown-preview {
  width: min(760px, 100%);
  padding: 28px 32px 48px;
  line-height: 1.65;
}

.markdown-preview > :first-child {
  margin-top: 0;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4 {
  margin: 1.45em 0 0.45em;
  line-height: 1.2;
}

.markdown-preview p,
.markdown-preview ul,
.markdown-preview ol,
.markdown-preview blockquote,
.markdown-preview pre,
.markdown-preview table {
  margin: 0 0 1em;
}

.markdown-preview a {
  color: var(--accent-strong);
  font-weight: 700;
}

.markdown-preview blockquote {
  padding: 12px 16px;
  border-left: 4px solid var(--accent);
  background: #f4f8f8;
  color: #344054;
}

.markdown-preview code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #eef2f7;
  color: #1d2939;
}

.markdown-preview pre {
  overflow-x: auto;
  padding: 16px;
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-ink);
}

.markdown-preview pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.markdown-preview table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}

.markdown-preview th,
.markdown-preview td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: left;
}

.markdown-preview th {
  background: #f2f5f9;
}

.markdown-preview img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.error {
  color: #b42318;
  font-weight: 700;
}

@media (max-width: 760px) {
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .reader-panel {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

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

  .file-button {
    width: 100%;
  }

  .drop-zone {
    margin: 16px;
  }

  .document-area {
    grid-template-columns: 1fr;
  }

  .file-meta {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .markdown-preview {
    padding: 24px 18px 40px;
  }
}
