:root {
    --bg-color: #f0f4f8;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --input-bg: #ffffff;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --focus-border: #64748b;
    --focus-ring: rgba(100, 116, 139, 0.4);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --error-color: #ef4444;
    --error-hover: #dc2626;
    --transition: all 0.2s ease;
}

[data-theme="dark"] {
    --bg-color: #31353a;
    --card-bg: #26292d;
    --text-main: #f8fafc;
    --text-muted: #9ba1a6;
    --border-color: #4a5057;
    --input-bg: #1e2124;
    --primary: #60a5fa;
    --primary-hover: #93c5fd;
    --focus-border: #9ba1a6;
    --focus-ring: rgba(155, 161, 166, 0.4);
    --shadow-md: 0 8px 12px -3px rgb(0 0 0 / 0.3);
    --error-color: #f87171;
    --error-hover: #ef4444;
}

* {
    box-sizing: border-box;
    font-family: 'JetBrains Mono', monospace;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    padding: 1.5rem;
    margin: 0;
    transition: var(--transition);
    font-size: 16px;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
}

.theme-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.theme-label {
    font-size: 0.9rem;
    font-weight: 500;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.theme-switch {
    position: relative;
    width: 50px;
    height: 28px;
    background-color: var(--border-color);
    border-radius: 999px;
    cursor: pointer;
    transition: var(--transition);
}

.theme-switch:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    background-color: white;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

#darkModeToggle:checked + .theme-switch {
    background-color: var(--primary);
}

#darkModeToggle:checked + .theme-switch .toggle-thumb {
    transform: translateX(22px);
}

.main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
}

@media (min-width: 768px) {
    .main-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .full-width {
        grid-column: 1 / -1;
    }
    .settings-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1.25rem;
    }
    .output-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.25rem;
    }
}

.card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.card h2 {
    margin-top: 0;
    margin-bottom: 1.25rem;
    font-size: 1.2rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.mt-3 {
    margin-top: 0.75rem;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    position: relative;
    min-width: 0;
}

.lookup-group, .input-with-btn {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    width: 100%;
}

.lookup-group input, .input-with-btn input {
    width: 100%;
}

button {
    background-color: var(--primary);
    color: #ffffff;
    border: none;
    padding: 0 1.5rem;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

button:focus:not(:disabled) {
    box-shadow: 0 0 0 3px var(--focus-ring);
    outline: none;
}

button:disabled {
    background-color: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
}

.lookup-result {
    padding: 0.75rem 0.85rem;
    border-radius: 6px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    word-break: break-all;
    transition: var(--transition);
    margin-top: 0.25rem;
}

.lookup-result.success {
    border-color: #10b981;
    color: #10b981;
}

.lookup-result.error {
    border-color: var(--error-color);
    color: var(--error-color);
}

.ns-box {
    padding: 0.75rem 0.85rem;
    border-radius: 6px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
    min-height: 44px;
    color: var(--text-main);
    word-break: break-all;
    transition: var(--transition);
}

.ns-box ul {
    margin: 0;
    padding-left: 1.25rem;
}

.ns-box li {
    margin-bottom: 0.25rem;
}

.ns-box li:last-child {
    margin-bottom: 0;
}

label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    height: 38px;
    padding: 0.6rem 0.85rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

input.input-error {
    border-color: var(--error-color) !important;
}

input:focus, select:focus, .mock-textarea:focus-within {
    border-color: var(--focus-border);
    box-shadow: 0 0 0 3px var(--focus-ring);
    outline: none;
}

.no-focus {
    caret-color: transparent;
    cursor: default !important;
}

.no-focus:focus {
    box-shadow: none !important;
    border-color: var(--border-color) !important;
}

.error-msg {
    display: none;
    color: var(--error-color);
    font-size: 0.75rem;
    margin-top: 0.35rem;
    word-break: break-all;
}

.error-msg.active {
    display: block;
}

select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 14px;
    padding-right: 2.25rem;
    cursor: pointer;
}

[data-theme="dark"] select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ba1a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

select:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 var(--text-main);
}

.info-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: -0.15rem;
}

.email-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.25rem;
    width: 100%;
}

.email-chip {
    display: flex;
    align-items: stretch;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    overflow: hidden;
    height: 38px;
    width: 100%;
}

.email-chip span {
    padding: 0 0.85rem;
    display: flex;
    align-items: center;
    color: var(--text-main);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-chip .remove-btn {
    background-color: var(--border-color);
    color: var(--text-main);
    border: none;
    border-radius: 0;
    padding: 0 0.75rem;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    height: 100%;
    margin: 0;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.email-chip .remove-btn:hover {
    background-color: var(--error-color);
    color: #ffffff;
}

.mock-textarea {
    width: 100%;
    padding: 1rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-main);
    min-height: 150px;
    line-height: 1.5;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    transition: var(--transition);
}

.bind-row-name {
    color: var(--text-muted);
    word-break: break-all;
}

.bind-row-type {
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.bind-row-record {
    color: var(--text-main);
    word-break: break-all;
    white-space: pre-wrap;
    width: 100%;
}

.cf-dns-box {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
    background-color: var(--bg-color);
    padding: 1.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: 1.5rem;
}

.dns-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dns-field.type { width: 80px; }
.dns-field.name { width: 200px; }
.dns-field.content { flex: 1; min-width: 250px; }

.cf-dns-box input {
    background-color: var(--input-bg);
}

.copy-btn {
    height: 38px;
    padding: 0 1.5rem;
}

.ip-header-group {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
}
.ip-header-group h2 { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.ip-display-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 2rem 1rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.ip-huge-text {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    word-break: break-all;
    text-align: center;
    letter-spacing: -0.02em;
}

.copy-btn-large {
    height: 44px;
    padding: 0 2.5rem;
    font-size: 1.05rem;
}

.record-box {
    width: 100%;
    padding: 1rem;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-main);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: var(--transition);
    overflow-x: auto;
}

.record-item {
    display: flex;
    flex-direction: column;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    gap: 0.4rem;
}

.record-item:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.record-value {
    color: var(--text-main);
    font-weight: 500;
    word-break: break-all;
    white-space: pre-wrap;
    display: flex;
    align-items: flex-start;
}

.record-badge {
    background-color: var(--border-color);
    color: var(--text-main);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 0.6rem;
    display: inline-block;
    white-space: nowrap;
    line-height: 1.2;
    margin-top: 0.1rem;
}

.record-meta {
    color: var(--text-muted);
    font-size: 0.8rem;
    display: flex;
    gap: 1rem;
}

.placeholder-text {
    color: var(--text-muted);
    font-style: italic;
    width: 100%;
}

@media (max-width: 767px) {
    .cf-dns-box {
        flex-direction: column;
        align-items: stretch;
    }
    .dns-field.type, .dns-field.name, .dns-field.content {
        width: 100%;
    }
}

@media (min-width: 768px) {
    .ip-display-box {
        flex-direction: row;
        justify-content: space-between;
        padding: 2rem 3rem;
    }
    .ip-huge-text {
        text-align: left;
    }
}