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

:root {
    --bg: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f5f5f5;
    --bg-drop: #fafafa;
    --border: #e0e0e0;
    --border-light: #f0f0f0;
    --text: #000000;
    --text-secondary: #666666;
    --text-muted: #999999;
    --accent: #000000;
    --accent-hover: #333333;
    --success: #2d8a4e;
    --error: #c53030;
    --warning: #b7791f;
    --radius: 6px;
    --radius-lg: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0a0a0a;
        --bg-card: #111111;
        --bg-hover: #1a1a1a;
        --bg-drop: #0f0f0f;
        --border: #222222;
        --border-light: #1a1a1a;
        --text: #ffffff;
        --text-secondary: #999999;
        --text-muted: #666666;
        --accent: #ffffff;
        --accent-hover: #cccccc;
        --shadow: 0 1px 3px rgba(0,0,0,0.3);
        --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
    }
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ============ Layout ============ */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    max-width: 800px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.logo-icon { color: var(--text); }


.wallet-area { margin-left: auto; }

.wallet-address {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-hover);
    padding: 6px 10px;
    border-radius: var(--radius);
    overflow-wrap: anywhere;
}

main {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 32px 20px;
    width: 100%;
}

footer {
    border-top: 1px solid var(--border);
    padding: 16px 20px;
}

.footer-inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.footer-social {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

.footer-social:hover { color: var(--text); }

.footer-links { display: flex; gap: 6px; flex-wrap: wrap; }

.chain-badge {
    font-size: 10px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-muted);
}

/* ============ Views ============ */
.view { display: none; }
.view.active { display: block; }

/* ============ Card ============ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
}

.card h2 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

/* ============ Drop Zone ============ */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 14px;
    background: var(--bg-drop);
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--text-muted);
    background: var(--bg-hover);
}

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

.drop-zone.loading {
    border-color: var(--text-muted);
    border-style: solid;
    pointer-events: none;
}

.drop-status {
    font-size: 13px;
    color: var(--text-secondary);
}

.drop-icon { color: var(--text-muted); }

/* ============ Hash Result ============ */
.hash-result {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-hover);
    border-radius: var(--radius);
}

.hash-result label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    display: block;
    margin-bottom: 6px;
}

.hash-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hash-display code {
    font-family: var(--mono);
    font-size: 13px;
    word-break: break-all;
    flex: 1;
}

.file-info {
    margin-top: 8px;
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ============ Forms ============ */
.stamp-form { margin-top: 20px; }

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s;
}

input[type="text"]:focus {
    border-color: var(--accent);
}

input[type="checkbox"] {
    margin-right: 6px;
}

.input-row {
    display: flex;
    gap: 8px;
}

.input-row input { flex: 1; }

/* ============ Chain Select ============ */
.chain-select {
    margin-bottom: 20px;
}

.chain-select label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: block;
}

.chain-options {
    display: flex;
    gap: 6px;
}

.chain-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.15s;
}

.chain-btn.active {
    border-color: var(--accent);
    color: var(--text);
    background: var(--bg-hover);
}

.chain-btn:hover:not(.active) {
    border-color: var(--text-muted);
}

/* ============ Buttons ============ */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

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

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

.btn-outline {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover { background: var(--bg-hover); }

.btn-full { width: 100%; }

.btn-icon {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.btn-icon:hover { color: var(--text); }

.btn-loading { display: none; }
.btn.loading .btn-text { display: none; }
.btn.loading .btn-loading { display: inline-flex; align-items: center; gap: 6px; }

/* ============ Results ============ */
.stamp-result, .verify-result {
    margin-top: 20px;
    padding: 16px;
    border-radius: var(--radius);
    font-size: 14px;
}

/* One grid for the whole table, rather than a flex row per line: the label
   column is then sized once to the longest label and stays aligned down the
   table, instead of every row negotiating its own split. */
.result-success,
.result-not-found {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    column-gap: 28px;
    align-items: start;
    padding: 2px 16px;
    border-radius: var(--radius);
    background: var(--bg-hover);
}

.result-success { border: 1px solid var(--success); }
.result-not-found { border: 1px solid var(--border); }

.result-error {
    padding: 12px 16px;
    border-radius: var(--radius);
    background: var(--bg-hover);
    border: 1px solid var(--error);
    color: var(--error);
    font-size: 13px;
}

/* Rows are structural only; their cells belong to the grid above. */
.result-row { display: contents; }

.result-label,
.result-value {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    line-height: 1.5;
}

.result-row:last-child .result-label,
.result-row:last-child .result-value { border-bottom: none; }

.result-label {
    color: var(--text-muted);
    white-space: nowrap;
}

.result-value {
    text-align: right;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Identifiers — hashes, addresses, names — read better fixed-width. Dates and
   prose do not. */
.result-value.mono {
    font-family: var(--mono);
    font-size: 12px;
}

/* ============ Spinner ============ */
/* Negative angle: CSS rotates clockwise for positive values, so this spins
   counter-clockwise. */
@keyframes spin { to { transform: rotate(-360deg); } }

.spinner {
    animation: spin 0.8s linear infinite;
    transform-origin: center;
}

/* An SVG child element resolves transform-origin against the nearest viewBox,
   not its own box, so a bare `center` can sit off the shape and make it orbit
   instead of spin. fill-box pins the origin to the circle itself. */
circle.spinner {
    transform-box: fill-box;
}

/* ============ Utilities ============ */
.hidden { display: none !important; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============ Responsive ============ */
@media (max-width: 640px) {
    .header-inner { padding: 10px 16px; gap: 12px; }
    .logo-text { display: none; }
    .card { padding: 20px; }
    .drop-zone { padding: 32px 16px; }
    .chain-options { flex-wrap: wrap; }
    .footer-inner { flex-direction: column; gap: 8px; }
    /* Shrink rather than truncate: the whole address stays readable. */
    .wallet-address { font-size: 10px; padding: 5px 8px; }
}

/* ============ Toast ============ */

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 16px);
    max-width: min(560px, calc(100vw - 32px));
    padding: 12px 16px;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 2px solid var(--error);
    font-size: 13px;
    line-height: 1.5;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 100;
}

.toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.result-value a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ============ Transfer panel ============ */

.transfer-panel {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.panel-header svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.panel-header .chain-badge {
    margin-left: auto;
}

.transfer-panel .subtitle {
    margin: 4px 0 16px;
}

/* ============ Claim / AI panels ============ */

.claim-panel,
.ai-panel {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.claim-panel .panel-header {
    margin-bottom: 16px;
}

.result-pending {
    padding: 12px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.result-history {
    grid-column: 1 / -1;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

#btn-recheck {
    margin-top: 12px;
}

.ai-answer {
    margin-top: 12px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

.ai-answer > *:first-child { margin-top: 0; }
.ai-answer > *:last-child { margin-bottom: 0; }

.ai-answer h4,
.ai-answer h5,
.ai-answer h6 {
    margin: 18px 0 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.ai-answer p { margin: 0 0 10px; }

.ai-answer ul,
.ai-answer ol {
    margin: 0 0 10px;
    padding-left: 20px;
}

.ai-answer li { margin: 4px 0; }

/* Facts arrive as a two-column table; match the result panel's rhythm. */
.ai-answer table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 12px;
    font-size: 12.5px;
}

.ai-answer th {
    text-align: left;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding: 0 12px 6px 0;
}

.ai-answer td {
    padding: 7px 12px 7px 0;
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
}

.ai-answer th:last-child,
.ai-answer td:last-child { padding-right: 0; }

.ai-answer tr:last-child td { border-bottom: none; }

/* First column reads as a label, like the result panel. */
.ai-answer td:first-child {
    color: var(--text-muted);
    white-space: nowrap;
}

.ai-answer blockquote {
    margin: 0 0 10px;
    padding-left: 12px;
    border-left: 2px solid var(--border);
    color: var(--text-muted);
}

.ai-answer code {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--text);
    background: var(--bg-hover);
    padding: 1px 4px;
    border-radius: 3px;
}

.ai-answer strong { color: var(--text); font-weight: 600; }

.ai-answer hr {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 14px 0;
}

/* ============ Owner with ENS name ============ */

.owner-name {
    display: block;
    font-family: var(--font);
    font-size: 13px;
}

.owner-address {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

/* History rows carry an address and a date; keep them on separate lines. */
.history-date {
    display: block;
    font-family: var(--font);
    font-size: 11px;
    color: var(--text-muted);
}
