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

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ========== Header ========== */
header {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    text-align: center;
    padding: 2rem 1rem;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

header .subtitle {
    margin-top: 0.5rem;
    font-size: 1rem;
    opacity: 0.9;
}

/* ========== Main ========== */
main {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

/* ========== Current Timestamp ========== */
.current-timestamp {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.current-timestamp h2 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.timestamp-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.big-number {
    font-size: 2.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--primary);
    letter-spacing: -1px;
}

.unit-label {
    font-size: 1rem;
    color: var(--text-secondary);
}

.timestamp-actions {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.current-datetime {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.97);
}

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

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

.btn-secondary {
    background: #e2e8f0;
    color: var(--text);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-block {
    width: 100%;
    margin-top: 0.75rem;
}

.btn-sm {
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
}

/* ========== Tabs ========== */
.converter-section {
    margin-bottom: 1.5rem;
}

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1rem;
}

.tab {
    padding: 0.6rem 1.5rem;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ========== Convert Cards ========== */
.convert-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.convert-card h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.convert-row, .result-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.convert-row input[type="text"],
.result-row input[type="text"] {
    flex: 1;
    min-width: 180px;
}

input[type="text"], select, textarea {
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--text);
    background: #fff;
    transition: border-color 0.2s;
}

input[type="text"]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

input[readonly] {
    background: #f1f5f9;
}

.hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* ========== Batch ========== */
.batch-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.batch-input-row textarea {
    flex: 1;
    resize: vertical;
}

.batch-result {
    margin-top: 1rem;
}

.batch-result table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.batch-result th, .batch-result td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}

.batch-result th {
    background: #f1f5f9;
    font-weight: 600;
}

.batch-result tr:nth-child(even) {
    background: #f8fafc;
}

/* ========== Intro Section ========== */
.intro-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.intro-section h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.intro-section h3 {
    font-size: 1.05rem;
    margin: 1.2rem 0 0.5rem;
}

.intro-section p {
    margin-bottom: 0.75rem;
}

.intro-section ul {
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.intro-section li {
    margin-bottom: 0.3rem;
}

.intro-section code {
    background: #f1f5f9;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #be185d;
}

/* ========== Comments ========== */
.comments-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.comments-section h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.comment-form input[type="text"] {
    max-width: 300px;
}

.comment-form textarea {
    resize: vertical;
}

.comment-form .btn {
    align-self: flex-start;
}

.comments-list .loading {
    color: var(--text-secondary);
    font-style: italic;
}

.comment-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.comment-item:last-child {
    border-bottom: none;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.comment-nickname {
    font-weight: 600;
    font-size: 0.9rem;
}

.comment-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.comment-body {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.comment-actions .btn-reply {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0;
}

.comment-actions .btn-reply:hover {
    text-decoration: underline;
}

.comment-replies {
    margin-left: 1.5rem;
    padding-left: 1rem;
    border-left: 2px solid var(--border);
}

.reply-form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: var(--radius);
}

.reply-form input[type="text"] {
    max-width: 200px;
}

.reply-form textarea {
    resize: vertical;
    font-size: 0.85rem;
}

.reply-form-actions {
    display: flex;
    gap: 0.5rem;
}

/* ========== Footer ========== */
footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

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

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

/* ========== Toast ========== */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}

/* ========== Responsive ========== */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.4rem;
    }

    .big-number {
        font-size: 2rem;
    }

    .convert-row, .result-row {
        flex-direction: column;
    }

    .convert-row input[type="text"],
    .result-row input[type="text"] {
        min-width: auto;
        width: 100%;
    }

    .convert-row select,
    .result-row select {
        width: 100%;
    }

    .convert-row .btn {
        width: 100%;
    }

    .batch-input-row {
        flex-direction: column;
    }

    .batch-input-row select {
        width: 100%;
    }

    .comment-replies {
        margin-left: 0.75rem;
        padding-left: 0.75rem;
    }
}
