*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #0f1423;
    overflow-x: hidden;
}

.card {
    background: #ffffff;
    border-radius: 12px;
    padding: 32px 28px 28px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
    width: calc(100% - 32px);
    max-width: 900px;
    margin: 24px auto;
}

.logo {
    max-width: 180px;
    margin: 0 auto 24px;
    display: block;
}

.field {
    margin-bottom: 16px;
    text-align: left;
}

.label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: #374151;
}

.input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #fff4e1;
    font-size: 0.9rem;
    outline: none;
    box-sizing: border-box;
}

.input:focus {
    border-color: #111827;
    box-shadow: 0 0 0 1px #11182711;
}

.button {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: none;
    background: #52b54c;
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.button:hover {
    background: #469d41;
}

.error {
    margin-top: 6px;
    font-size: 0.8rem;
    color: #dc2626;
}

.success {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #16a34a;
}

.search-results {
    margin-top: 8px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    padding: 6px 8px;
    max-height: 220px;
    overflow-y: auto;
}

.search-item {
    padding: 8px 10px;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
}

.search-item a {
    text-decoration: none;
    color: #166e11;
    font-weight: 600;
    display: block;
}

.search-item:hover {
    background: transparent;
}

.search-empty {
    font-size: 0.8rem;
    color: #6b7280;
    padding: 4px 2px;
}

#search {
    background: #ffffff;
    border-radius: 5px;
    border: 1px solid #cbcbcb;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
    color: #1f2937;
    letter-spacing: 0.01em;
}

#search::placeholder {
    color: #9aa1ab;
    font-weight: 400;
}

#search:focus {
    border-color: #52b54c;
    box-shadow: 0 0 0 1px #52b54c40;
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 24px;
}

.tile {
    border-radius: 0;
    border: 0;
    border-bottom: 3px solid #52b54c;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #111827;
    background: transparent;
    text-decoration: none;
    display: block;
    text-align: left;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.tile:hover {
    background: #fff9e8;
    border-color: #52b54c;
    transform: translateY(-1px);
}

.section-title {
    margin: 32px 0 0;
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.page {
    width: 100%;
}

.topbar {
    background: #ffffff;
    border-radius: 0;
    padding: 14px 18px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    margin-bottom: 16px;
    width: 100%;
}

.topbar .logo {
    margin: 0 auto;
    max-width: 150px;
}

.topbar-inner .logo {
    margin: 0;
}

.topbar-inner {
    width: calc(100% - 32px);
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar-right {
    text-align: right;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.topbar-subtitle {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 4px;
}

.topbar-nav {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.8rem;
    color: #52b54c;
    text-decoration: none;
    font-weight: 600;
}

.topbar-nav:hover {
    text-decoration: underline;
    color: #469d41;
}

.content-box {
    background: #ffffff;
    border-radius: 5px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    max-width: 1100px;
    width: calc(100% - 32px);
    margin: 0 auto 16px;
}

.search-content-box {
    background: #fff8ef;
    border: 1px solid #ffe2bf;
}

.search-content-box .field {
    margin-bottom: 0;
}

.categories-content-box .section-title {
    margin-top: 0;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}

.header .logo {
    max-width: 140px;
    margin: 0;
}

.header-meta {
    text-align: right;
}

.title {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.subtitle {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 4px;
}

.list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.item {
    border-radius: 0;
    border: 0;
    border-bottom: 3px solid #52b54c;
    padding: 10px 20px;
    margin-bottom: 8px;
    background: transparent;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.item a {
    text-decoration: none;
    color: #111827;
    font-size: 0.9rem;
    font-weight: 500;
    display: block;
}

.item:hover {
    background: #fff9e8;
    border-color: #52b54c;
    transform: translateY(-1px);
}

.item-empty {
    background: #f9fafb;
    border-style: dashed;
}

.item-empty-text {
    font-size: 0.85rem;
    color: #6b7280;
}

.content {
    margin-top: 12px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #111827;
}

.content h1,
.content h2,
.content h3 {
    margin-top: 1.25em;
    margin-bottom: 0.5em;
}

.content ul,
.content ol {
    padding-left: 1.25em;
    margin-top: 0.5em;
    margin-bottom: 0.75em;
}

.add-tag-wrap {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
}

.add-tag-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(100%, 520px);
}

.add-tag-button {
    border: 1px solid #54b740;
    background: #ffffff;
    color: #54b740;
    border-radius: 5px;
    padding: 9px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
    cursor: pointer;
}

.add-tag-button:hover {
    background: #f3faef;
    border-color: #54b740;
    color: #3d922f;
    transform: translateY(-1px);
}

.add-tag-input-wrap {
    flex: 1;
}

.add-tag-input {
    width: 100%;
    border: 1px solid #cbcbcb;
    border-radius: 5px;
    padding: 9px 12px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #1f2937;
    background: #ffffff;
    outline: none;
}

.add-tag-input:focus {
    border-color: #54b740;
    box-shadow: 0 0 0 1px #54b74040;
}

.front-tags-wrap {
    margin-top: 0;
}

.tags-content-box {
    margin-top: 0;
}

.front-tags-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 6px;
}

.front-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.front-tag-item {
    display: inline-flex;
    align-items: center;
    border: 1px solid #cfe8cc;
    background: #f3faef;
    color: #166e11;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 600;
}

.confirm-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 35, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 2000;
}

.confirm-modal-card {
    width: min(100%, 460px);
    background: #ffffff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
}

.confirm-modal-text {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.45;
    color: #1f2937;
}

.confirm-modal-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.confirm-btn {
    border-radius: 5px;
    padding: 9px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
}

.confirm-btn-primary {
    border: 1px solid #54b740;
    background: #54b740;
    color: #ffffff;
}

.confirm-btn-primary:hover {
    background: #469d41;
    border-color: #469d41;
}

.confirm-btn-outline {
    border: 1px solid #54b740;
    background: #ffffff;
    color: #54b740;
}

.confirm-btn-outline:hover {
    background: #f3faef;
}

.back-wrap {
    margin-top: 16px;
    text-align: right;
}

.back {
    font-size: 0.8rem;
    color: #6b7280;
    text-decoration: none;
}

.back:hover {
    text-decoration: underline;
}

.empty-categories {
    grid-column: 1 / -1;
    font-size: 0.9rem;
    color: #6b7280;
    text-align: center;
    margin-top: 8px;
}

@media (max-width: 768px) {
    .card {
        max-width: none;
        margin: 16px auto;
    }

    .page {
        margin: 0;
    }

    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar-inner {
        width: calc(100% - 24px);
    }

    .content-box {
        width: calc(100% - 24px);
    }
}
