/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #ffffff;
  --color-text: #111827;
  --color-text-secondary: #6b7280;
  --color-border: #e5e7eb;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-error: #dc2626;
  --color-error-bg: #fef2f2;
  --color-code-bg: #f3f4f6;
  --color-table-stripe: #f9fafb;
  --max-width: 768px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  border-bottom: 1px solid var(--color-border);
  padding: 16px 24px;
}

.logo-link {
  display: inline-block;
}

.logo {
  height: 28px;
  width: auto;
}

/* Main */
.main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px;
}

/* Footer */
.footer {
  border-top: 1px solid var(--color-border);
  padding: 24px;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

.footer a {
  color: var(--color-primary);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* Share Content */
.share-content h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 32px;
  line-height: 1.3;
}

/* Markdown Body */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  font-weight: 600;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  line-height: 1.3;
}

.markdown-body h1 { font-size: 1.5rem; }
.markdown-body h2 { font-size: 1.25rem; }
.markdown-body h3 { font-size: 1.125rem; }

.markdown-body p {
  margin-bottom: 1em;
}

.markdown-body a {
  color: var(--color-primary);
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body ul,
.markdown-body ol {
  margin-bottom: 1em;
  padding-left: 1.5em;
}

.markdown-body li {
  margin-bottom: 0.25em;
}

.markdown-body blockquote {
  border-left: 4px solid var(--color-border);
  padding-left: 1em;
  color: var(--color-text-secondary);
  margin-bottom: 1em;
}

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-code-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.markdown-body pre {
  background: var(--color-code-bg);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1em;
}

.markdown-body pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2em 0;
}

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

/* Tables */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1em;
  font-size: 0.875rem;
  overflow-x: auto;
  display: block;
}

.markdown-body thead th {
  background: var(--color-code-bg);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}

.markdown-body tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
}

.markdown-body tbody tr:nth-child(even) {
  background: var(--color-table-stripe);
}

/* Attachments */
.attachments {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
}

.attachments h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.attachments ul {
  list-style: none;
  padding: 0;
}

.attachments li {
  margin-bottom: 8px;
}

.attachments a {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.875rem;
}

.attachments a::before {
  content: "\2193\00a0";
}

.attachments a:hover {
  text-decoration: underline;
}

/* Gate (Email / OTP Forms) */
.gate-container {
  max-width: 400px;
  margin: 80px auto 0;
  text-align: center;
}

.gate-container h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.gate-container .share-title {
  color: var(--color-text-secondary);
  font-style: italic;
  margin-bottom: 24px;
}

.gate-container p {
  color: var(--color-text-secondary);
  margin-bottom: 24px;
}

.gate-container p strong {
  color: var(--color-text);
}

.gate-form {
  text-align: left;
}

.gate-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--color-text);
}

.gate-form input[type="email"],
.gate-form input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.15s;
}

.gate-form input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.gate-form button {
  width: 100%;
  padding: 10px 16px;
  font-size: 1rem;
  font-weight: 500;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.gate-form button:hover {
  background: var(--color-primary-hover);
}

.form-error {
  background: var(--color-error-bg);
  color: var(--color-error);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 16px;
  text-align: left;
}

.resend-link {
  font-size: 0.875rem;
  margin-top: 16px;
}

.resend-link a {
  color: var(--color-primary);
  text-decoration: none;
  cursor: pointer;
}

.resend-link a:hover {
  text-decoration: underline;
}

/* Error Pages */
.error-container {
  max-width: 400px;
  margin: 80px auto 0;
  text-align: center;
}

.error-container h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.error-container p {
  color: var(--color-text-secondary);
  margin-bottom: 24px;
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  background: var(--color-primary);
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s;
}

.btn:hover {
  background: var(--color-primary-hover);
}

/* Responsive */
@media (max-width: 640px) {
  .main {
    padding: 24px 16px;
  }

  .share-content h1 {
    font-size: 1.375rem;
  }

  .gate-container {
    margin-top: 40px;
  }

  .error-container {
    margin-top: 40px;
  }

  .markdown-body table {
    font-size: 0.8125rem;
  }

  .markdown-body thead th,
  .markdown-body tbody td {
    padding: 6px 8px;
  }
}
