
* {
    box-sizing: border-box;
    font-family: sans-serif;
}

html {
    background-color: #420;
}

body {
    margin: 0;
    xpadding: 2em 2vw;
    background-color: #fffe;
    min-height: 100vh;
}

body.page-no-scroll {
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

busy {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10;
}

user {
    position: absolute;
    top: 1em;
    right: 1em;
    z-index: 9;
    font-size: 3em;
}

.hid {
    display: none !important;
}

.journal-record {
    background: #fff;
    border-radius: 0.5em;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    margin: 1em 0;
    padding: 1.2em 1.5em;
    display: flex;
    align-items: center;
    transition: box-shadow 0.2s;
}

.journal-record:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
}

.journal-record a {
    color: #420;
    text-decoration: none;
    font-size: 1.2em;
    font-weight: 600;
    flex: 1;
    word-break: break-word;
    transition: color 0.2s;
}

.journal-record a:hover {
    color: #a60;
    text-decoration: underline;
}

.journal-actions {
    display: flex;
    align-items: center;
    gap: 0.5em;
    margin-left: 1em;
}

.journal-action-group {
    display: flex;
    gap: 0.5em;
}

.journal-action-delete {
    display: flex;
    gap: 0.5em;
}

.subtitle {
    text-align: center;
    font-size: 1.5em;
    color: #666;
    font-style: italic;
    margin-bottom: 1em;
}

.new-btn {
    display: block;
    margin: 0 auto 1.5em auto;
    padding: 0.6em 1.2em;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 0.4em;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s;
}

.new-btn:hover {
    background: #1976d2;
}

h1 {
    text-align: center;
    font-size: 2.2em;
    margin-top: 0.5em;
    margin-bottom: 1.2em;
    letter-spacing: 0.02em;
    color: #420;
    font-weight: 700;
}

.story-record {
    background: #fff;
    border-radius: 0.5em;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    margin: 1em 0;
    padding: 1.2em 1.5em;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: box-shadow 0.2s;
}

.story-record:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
}

.story-record:hover a {
    color: #a60;
}

.story-record a {
    color: #420;
    text-decoration: none;
    font-size: 1.1em;
    font-weight: 500;
    flex: 1;
    word-break: break-word;
    transition: color 0.2s;
    display: block;
    width: 100%;
}

.story-content {
    width: 100%;
}

.story-title {
    font-size: 1.3em;
    font-weight: 700;
    margin-bottom: 0.3em;
}

story-title {
    font-size: 1.3em;
    font-weight: 700;
    margin-bottom: 0.3em;
    color: #420;
    display: block;
}

.story-meta {
    display: flex;
    gap: 1.2em;
    font-size: 0.98em;
    color: #666;
    margin-top: 0.3em;
    margin-left: 0.2em;
    flex-wrap: wrap;
}

.story-author {
    font-style: italic;
    color: #666;
    display: block;
    margin-top: 0.2em;
    margin-bottom: 0.1em;
}

.story-journal {
    color: #1976d2;
    font-weight: 500;
    display: inline;
}

story-author {
    font-style: italic;
    color: #666;
    display: inline;
}

story-created {
    color: #a60;
    font-family: monospace;
    font-size: 0.9em;
    display: block;
    margin: 0.5em 0;
}

story-published {
    color: #1976d2;
    font-family: monospace;
    font-size: 0.95em;
    display: block;
    margin-bottom: 0.2em;
    margin-left: 0.1em;
}

story-visible {
    color: #666;
    font-size: 0.9em;
    display: block;
    margin: 0.5em 0;
}

story-image,
story-image-url {
    display: block;
    color: #666;
    font-size: 0.9em;
    margin: 0.5em 0;
}

story-blurb {
    color: #666;
    font-style: italic;
    display: block;
    margin: 1em 0;
    padding: 0.8em;
    background: #f9f9f9;
    border-left: 3px solid #a60;
    border-radius: 0.3em;
}

.story-blurb {
    color: #666;
    font-style: italic;
    display: block;
    margin: 1em 0;
    padding: 0.8em;
    background: #f9f9f9;
    border-left: 3px solid #a60;
    border-radius: 0.3em;
}

story-body {
    display: block;
    margin-top: 1.5em;
    line-height: 1.6;
}

.story-date {
    color: #a60;
    font-family: monospace;
    font-size: 0.95em;
    display: block;
    margin-bottom: 0.2em;
    margin-left: 0.1em;
}

.story-actions {
    display: flex;
    gap: 0.5em;
    margin-left: 1em;
    align-items: center;
}

.story-action-group {
    display: flex;
    gap: 0.5em;
}

.story-action-delete {
    margin-left: 1.5em;
    display: flex;
    align-items: center;
}

.edit-btn, .delete-btn {
    padding: 0.4em 0.8em;
    border: none;
    border-radius: 0.3em;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
}

.edit-btn {
    background: #420;
    color: white;
}

.edit-btn:hover {
    background: #a60;
}

.delete-btn {
    background: #d32f2f;
    color: white;
    margin-left: 1.2em;
    box-shadow: 0 0 0 2px #fff, 0 2px 8px rgba(211,47,47,0.08);
    border: 2px solid #d32f2f;
}

.delete-btn:hover {
    background: #b71c1c;
    border-color: #b71c1c;
}

.publish-btn {
    background: #2196f3;
    color: white;
    padding: 0.4em 0.8em;
    border: none;
    border-radius: 0.3em;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
}

.publish-btn:hover {
    background: #1976d2;
}

.visible-btn {
    background: #43a047;
    color: white;
    padding: 0.4em 0.8em;
    border: none;
    border-radius: 0.3em;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
}

.visible-btn:hover {
    background: #2e7031;
}

.view-btn {
    background: #ff9800;
    color: white;
    padding: 0.4em 0.8em;
    border: none;
    border-radius: 0.3em;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
}

.view-btn:hover {
    background: #f57c00;
}

#story_editor {
    display: flex;
    gap: 2em;
    min-height: 4em;
    margin: 0;
    padding: 1em 2vw;
    flex: 1;
    overflow: hidden;
}

#story_editor textarea {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 1em;
    border: 1px solid #ccc;
    border-radius: 0.5em;
    font-family: monospace;
    font-size: 0.9em;
    line-height: 1.4;
    resize: none;
    background: #fff;
}

#story_editor formatted {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 1em;
    border: 1px solid #ccc;
    border-radius: 0.5em;
    background: #fff;
    overflow-y: auto;
    line-height: 1.6;
}

@media (max-width: 768px) {
    #story_editor {
        flex-direction: column;
        gap: 1em;
    }
    
    #story_editor textarea,
    #story_editor formatted {
        min-height: 200px;
        flex: 1;
    }
}

@media (max-width: 600px) {
    .journal-record {
        padding: 1em 0.7em;
        font-size: 1em;
    }
    .journal-record a {
        font-size: 1em;
    }
    h1 {
        font-size: 1.4em;
        margin-top: 0.7em;
        margin-bottom: 1em;
    }
    .story-record {
        padding: 1em 0.7em;
        font-size: 1em;
    }
    .story-record a {
        font-size: 1em;
    }
    .story-meta {
        flex-direction: column;
        gap: 0.2em;
        font-size: 0.95em;
    }
    .story-actions {
        flex-direction: column;
        gap: 0.3em;
        margin-left: 0;
        align-items: stretch;
    }
    .story-action-group {
        flex-direction: column;
        gap: 0.3em;
    }
    .story-action-delete {
        margin-left: 0;
        margin-top: 0.7em;
    }
    
    .journal-actions {
        flex-direction: column;
        gap: 0.3em;
        margin-left: 0;
        align-items: stretch;
    }
    .journal-action-group {
        flex-direction: column;
        gap: 0.3em;
    }
    .journal-action-delete {
        margin-left: 0;
        margin-top: 0.7em;
    }
    
    .edit-btn, .delete-btn, .view-btn {
        padding: 0.3em 0.6em;
        font-size: 0.85em;
    }
    .new-btn {
        padding: 0.5em 1em;
        font-size: 0.95em;
    }
    .publish-btn {
        padding: 0.3em 0.6em;
        font-size: 0.85em;
    }
    .visible-btn {
        padding: 0.3em 0.6em;
        font-size: 0.85em;
    }
    .delete-btn {
        margin-left: 0;
        margin-top: 0.5em;
    }
}

@media (min-width: 900px) {
    .journal-record {
        max-width: 700px;
        margin-left: auto;
        margin-right: auto;
    }
    .story-record {
        max-width: 700px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* Login form styles */
.login-form {
    max-width: 400px;
    margin: 2em auto 0 auto;
    padding: 0 1em;
}

.form-group {
    margin-bottom: 1.5em;
}

.form-group label {
    display: block;
    margin-bottom: 0.5em;
    color: #420;
    font-weight: 600;
    font-size: 1em;
}

.form-group input {
    width: 100%;
    padding: 0.8em;
    border: 2px solid #ddd;
    border-radius: 0.4em;
    font-size: 1em;
    background: #fff;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #2196f3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.login-btn {
    width: 100%;
    padding: 0.8em;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 0.4em;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.login-btn:hover {
    background: #1976d2;
}

.login-btn:active {
    transform: translateY(1px);
}

/* Password container and toggle button styles */
.password-container {
    position: relative;
    display: flex;
    align-items: center;
}

.password-container input {
    padding-right: 4em; /* Make room for the toggle button */
}

.toggle-password-btn {
    position: absolute;
    right: 0.5em;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #666;
    font-size: 0.9em;
    cursor: pointer;
    padding: 0.3em 0.6em;
    border-radius: 0.3em;
    transition: all 0.2s;
}

.toggle-password-btn:hover {
    background: #f0f0f0;
    color: #420;
}

/* Search box styles */
.search-container {
    max-width: 700px;
    margin: 0 auto 1.5em auto;
    padding: 0 2vw;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box input {
    width: 100%;
    padding: 0.8em 2.5em 0.8em 1em;
    border: 2px solid #ddd;
    border-radius: 0.5em;
    font-size: 1em;
    background: #fff;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.search-box input:focus {
    outline: none;
    border-color: #2196f3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1), 0 2px 8px rgba(0,0,0,0.1);
}

.search-box input::placeholder {
    color: #999;
    font-style: italic;
}

.search-clear-btn {
    position: absolute;
    right: 0.8em;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    font-size: 1.2em;
    cursor: pointer;
    padding: 0.2em;
    border-radius: 50%;
    width: 1.8em;
    height: 1.8em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0;
    pointer-events: none;
}

.search-clear-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.search-clear-btn:hover {
    background: #f0f0f0;
    color: #666;
}

/* Search results page styles */
#search-results {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 2vw;
}

#search-results p {
    text-align: center;
    color: #666;
    font-size: 1.1em;
    margin: 2em 0;
}

#loading p {
    color: #2196f3;
    font-weight: 500;
}

#no-results p {
    color: #666;
    font-style: italic;
}

#no-results p.error {
    color: #d32f2f;
    font-style: normal;
}

/* Mobile optimizations for login form */
@media (max-width: 600px) {
    .login-form {
        max-width: 100%;
        padding: 0 1.5em;
        margin-top: 1.5em;
    }
    
    .form-group input {
        padding: 0.9em;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .password-container input {
        padding-right: 4.5em; /* Slightly more room on mobile */
    }
    
    .toggle-password-btn {
        font-size: 0.85em;
        padding: 0.4em 0.7em;
    }
    
    .login-btn {
        padding: 0.9em;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .search-container {
        padding: 0 1.5em;
        margin-bottom: 1em;
    }
    
    .search-box input {
        padding: 0.9em 2.8em 0.9em 1.2em;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

.page-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1em;
    margin: 0;
    padding: 1em 2vw;
    background-color: #fffe;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.heading h1,
.heading .back-link,
.heading .new-btn {
    min-height: 2.5em;
    line-height: 2.5em;
    margin-top: 0;
    margin-bottom: 0;
    display: flex;
    align-items: center;
}

.heading h1 {
    flex: 1 1 auto;
    font-size: 1.5em;
    text-align: left;
}

.heading .back-link {
    flex: 0 0 auto;
    text-align: center;
    color: #2196f3;
    text-decoration: none;
    font-size: 1em;
    padding: 0.4em 1em;
    border-radius: 0.3em;
    background: #f5faff;
    transition: background 0.2s;
}

.heading .back-link:hover {
    background: #e3f2fd;
    text-decoration: underline;
}

.heading .word-count {
    flex: 0 0 auto;
    color: #666;
    font-size: 0.9em;
    font-family: monospace;
    padding: 0.4em 1em;
    background: #f5f5f5;
    border-radius: 0.3em;
    border: 1px solid #ddd;
}

.heading .logo {
    height: 3em;
    width: auto;
    flex: 0 0 auto;
}

.heading .new-btn {
    flex: 0 0 auto;
    margin-left: auto;
}

@media (max-width: 700px) {
    .heading {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5em;
        padding: 0.5em 2vw;
    }
    .heading h1, .heading .back-link, .heading .word-count, .heading .new-btn {
        text-align: center;
        margin: 0.2em 0;
        min-height: unset;
        line-height: unset;
        display: block;
        align-items: unset;
    }
    .heading .new-btn {
        margin-left: 0;
    }
    .heading .word-count {
        margin: 0.2em auto;
        width: fit-content;
    }
}