/* ===== Variables ===== */
:root {
  --bg: #0d1117;
  --bg-2: #161b22;
  --bg-3: #21262d;
  --border: #30363d;
  --border-2: #3d444d;
  --text: #e6edf3;
  --text-muted: #7d8590;
  --text-subtle: #484f58;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --success: #3fb950;
  --error: #f85149;
  --warning: #d29922;
  --radius: 6px;
  --radius-lg: 12px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; display: block; }
input, select, textarea, button { font: inherit; }
/* Ensure the HTML hidden attribute always wins over display rules below
   (e.g. .alert/.result-box use display:flex which would otherwise show them). */
[hidden] { display: none !important; }

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.25rem;
}
main.container { flex: 1; padding-top: 2rem; padding-bottom: 3rem; }

/* ===== Header ===== */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: -.02em;
}
.logo:hover { color: var(--text); opacity: .85; }
.site-header nav a {
  font-size: .875rem;
  color: var(--text-muted);
  padding: .375rem .75rem;
  border-radius: var(--radius);
}
.site-header nav a:hover { background: var(--bg-3); color: var(--text); }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  margin-top: auto;
}
.site-footer p { font-size: .8rem; color: var(--text-subtle); text-align: center; }
.site-footer .footer-links { margin-top: .35rem; }
.site-footer .footer-links a { color: var(--text-muted); }
.site-footer .footer-links a:hover { color: var(--text); }

/* ===== Document / static content page ===== */
.doc { max-width: 760px; margin: 0 auto; }
.doc h1 { font-size: 1.5rem; letter-spacing: -.02em; margin-bottom: 1rem; }
.doc h2 {
  font-size: 1.05rem;
  color: var(--text);
  margin: 1.9rem 0 .6rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
}
.doc p { color: var(--text-muted); margin-bottom: .7rem; }
.doc ul { padding-left: 1.25rem; margin-bottom: .7rem; }
.doc li { color: var(--text-muted); margin-bottom: .4rem; }
.doc strong { color: var(--text); font-weight: 600; }
.doc code {
  font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
  font-size: .85em;
  background: var(--bg-3);
  padding: .1rem .35rem;
  border-radius: 4px;
  color: var(--accent);
  word-break: break-all;
}
.doc .contact-box {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.35rem;
  margin: 1rem 0 1.25rem;
}
.doc .contact-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}
.doc .contact-email {
  font-size: 1.15rem;
  font-weight: 600;
  font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
  word-break: break-all;
}
.doc .contact-hint { margin-top: .25rem; }
.doc .updated { color: var(--text-subtle); font-size: .8rem; margin: 1.75rem 0 1.25rem; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  line-height: 1;
  transition: background .15s, opacity .15s, border-color .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #0d1117;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-3); color: var(--text); border-color: var(--border-2); }
.btn-danger {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}
.btn-danger:hover:not(:disabled) { opacity: .88; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-report { color: var(--error) !important; border-color: transparent !important; }
.btn-report:hover { border-color: var(--error) !important; background: rgba(248,81,73,.1) !important; }
.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: inherit;
  padding: 0; text-decoration: underline;
}

/* ===== Tabs ===== */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  gap: .25rem;
}
.tab {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .65rem 1.1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ===== Upload Card ===== */
.upload-section { max-width: 820px; margin: 0 auto; }
.upload-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Form ===== */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.flex-1 { flex: 1; min-width: 140px; }
select {
  width: 100%;
  padding: .5rem .75rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d8590' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2rem;
}
select:focus { outline: none; border-color: var(--accent); }
.select-narrow { max-width: 200px; }
.code-input {
  width: 100%;
  padding: .75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: .85rem;
  resize: vertical;
  min-height: 320px;
  line-height: 1.6;
}
.code-input:focus { outline: none; border-color: var(--accent); }
.char-count {
  font-size: .75rem;
  color: var(--text-subtle);
  text-align: right;
  margin-top: .3rem;
}
.form-actions { display: flex; justify-content: flex-end; margin-top: .5rem; }
.form-msg {
  margin-top: .75rem;
  font-size: .85rem;
  padding: .5rem .75rem;
  border-radius: var(--radius);
}

/* ===== Drop Zone ===== */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
  overflow: hidden;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(88,166,255,.05);
}
.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 2rem;
  color: var(--text-muted);
  text-align: center;
}
.drop-zone-inner svg { color: var(--text-subtle); margin-bottom: .5rem; }
.drop-hint { font-size: .8rem; color: var(--text-subtle); }
.image-preview {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  padding: 1rem;
}
.image-preview img {
  max-height: 300px;
  border-radius: var(--radius);
  object-fit: contain;
}
.preview-info {
  display: flex;
  gap: 1rem;
  font-size: .8rem;
  color: var(--text-muted);
}

/* ===== Result Box ===== */
.result-box {
  margin-top: 1.25rem;
  background: var(--bg-2);
  border: 1px solid var(--success);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.result-icon.success { color: var(--success); flex-shrink: 0; }
.result-content { flex: 1; min-width: 0; }
.result-label { font-size: .8rem; color: var(--text-muted); margin-bottom: .5rem; }
.result-link-row {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.result-url {
  flex: 1;
  min-width: 0;
  padding: .45rem .75rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: .875rem;
  font-family: monospace;
}
.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .85rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.btn-copy:hover { background: var(--border); color: var(--text); }

/* ===== Alerts ===== */
.alert {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-top: 1rem;
}
.alert-error { background: rgba(248,81,73,.1); border: 1px solid rgba(248,81,73,.3); color: var(--error); }

/* ===== View Page ===== */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.view-meta {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.view-actions {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.meta-item {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .8rem;
  color: var(--text-muted);
}
.badge {
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-lang { background: rgba(88,166,255,.15); color: var(--accent); }
.badge-warn { background: rgba(210,153,34,.15); color: var(--warning); }

/* ===== Code View ===== */
.code-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: auto;
}
.code-container pre {
  margin: 0;
  padding: 1.25rem;
  font-size: .875rem;
  line-height: 1.65;
  white-space: pre;
  overflow-x: auto;
  background: transparent !important;
}
.code-container code { background: transparent !important; font-size: inherit; }

/* ===== Image View ===== */
.image-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.shared-image {
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius);
}
.original-name {
  margin-top: .75rem;
  font-size: .8rem;
  color: var(--text-subtle);
}

/* ===== Error Page ===== */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 40vh;
  text-align: center;
}
.error-code {
  font-size: 5rem;
  font-weight: 800;
  color: var(--text-subtle);
  line-height: 1;
}
.error-msg { font-size: 1.1rem; color: var(--text-muted); }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
}
.modal-box {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  width: 100%;
  max-width: 460px;
  z-index: 1;
}
.modal-box h3 { margin-bottom: 1.25rem; font-size: 1rem; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: 1.25rem;
}
textarea {
  width: 100%;
  padding: .5rem .75rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent); }

/* ===== Progress ===== */
.progress-bar {
  height: 3px;
  background: var(--bg-3);
  border-radius: 99px;
  overflow: hidden;
  margin-top: .75rem;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width .2s;
  border-radius: 99px;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .form-row { flex-direction: column; gap: .75rem; }
  .view-header { flex-direction: column; align-items: flex-start; }
  .result-link-row { flex-wrap: wrap; }
  .result-url { min-width: 0; width: 100%; }
  .modal-box { margin: 1rem; }
}
