* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    display: grid;
    place-items: center;
    background: #f4f7f2;
    color: #172033;
    font-family: "Courier New", Courier, monospace;
}

.app {
    width: min(900px, calc(100% - 32px));
    min-height: 500px;
    padding: 32px;
}

.view {
    display: none;
}

.view.active {
    display: flex;
}

#projects-view {
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
}

#home-view.active,
#auth-view.active {
    align-items: center;
    justify-content: center;
}

.home-card,
.auth-box {
    width: min(440px, 100%);
    min-height: 0;
    border: 1px solid #d5ddd0;
    border-radius: 22px;
    padding: 32px;
    background: white;
    box-shadow: 0 12px 35px rgba(23, 32, 51, 0.08);
}

.home-card {
    text-align: center;
}

.home-card h1,
.dashboard-header h1 {
    margin: 0;
}

.home-card p {
    color: #5d6757;
    font-family: Arial, sans-serif;
    line-height: 1.5;
}

.home-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

.auth-box {
    align-items: stretch;
    justify-content: flex-start;
    gap: 14px;
    text-align: left;
}

.auth-box h2 {
    margin: 0;
}

.auth-box form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-field[hidden] {
    display: none;
}

.auth-box label {
    font-size: 14px;
    font-weight: 700;
}

.auth-box input {
    width: 100%;
    height: 44px;
    border: 1px solid #aeb8a7;
    border-radius: 10px;
    padding: 0 12px;
    font-family: inherit;
}

.auth-box form .gbutton {
    width: 100%;
    margin-top: 8px;
}

.auth-message {
    min-height: 1.2em;
    margin: 0;
    color: #5d6757;
    font-family: Arial, sans-serif;
    font-size: 13px;
    line-height: 1.45;
}

.auth-message:not(:empty) {
    padding: 8px 10px;
    border-radius: 8px;
    background: #f2f5ef;
}

.text-button {
    border: 0;
    padding: 6px;
    background: transparent;
    color: #355b2c;
    font: inherit;
    cursor: pointer;
}

.text-button:hover,
.text-button:focus-visible {
    text-decoration: underline;
}

#auth-forgot-password {
    align-self: flex-start;
    margin-top: -8px;
}

#auth-switch {
    align-self: center;
}

button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.dashboard-header {
    width: 100%;
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.dashboard-header p {
    margin: 6px 0 0;
    color: #5d6757;
    font-family: Arial, sans-serif;
    font-size: 13px;
}

.dashboard-message {
    flex: 0 0 100%;
    margin: 0;
    color: #5d6757;
    font-family: Arial, sans-serif;
    font-size: 13px;
}

.dashboard-message.error {
    padding: 10px 12px;
    border-radius: 10px;
    background: #fde8e8;
    color: #7a2020;
}

.dashboard-header .secondary-button {
    min-width: 120px;
}

.projectbox {
    width: 220px;
    min-height: 220px;
    border: 2px dotted #819178;
    border-radius: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px;
    text-align: center;
    background: white;
}

.projectbox h2 {
    margin: 0;
}

.gbutton,
.secondary-button {
    min-width: 180px;
    min-height: 42px;
    border: 0;
    border-radius: 25px;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
}

.gbutton {
    background: #adff2f;
}

.gbutton:hover,
.gbutton:focus-visible {
    background: #91df1c;
}

.secondary-button {
    background: #e6eae3;
}

.project-list {
    display: contents;
}

.created-project {
    width: 220px;
    border-style: solid;
    border-color: #cfd8c9;
    align-items: stretch;
    justify-content: space-between;
    gap: 10px;
    padding: 14px;
    cursor: default;
    font-family: inherit;
}

.project-open {
    width: 100%;
    min-width: 0;
    min-height: 132px;
    border: 0;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: transparent;
    font-family: inherit;
    cursor: pointer;
}

.project-open strong {
    font-size: 18px;
    overflow-wrap: anywhere;
}

.project-open span {
    color: #5d6757;
    font-size: 13px;
}

.created-project:hover {
    border-color: #91df1c;
}

#settings-view.active {
    justify-content: center;
}

.settings-box {
    width: min(620px, 100%);
    min-height: 0;
    position: relative;
    align-items: stretch;
    justify-content: flex-start;
    text-align: left;
    gap: 12px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

.settings-box form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.app-error:not([hidden]) {
    margin: 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fde8e8;
    color: #7a2020;
    font-family: Arial, sans-serif;
    font-size: 13px;
    line-height: 1.4;
}

#projects-view .app-error:not([hidden]) {
    flex-basis: 100%;
}

.setting-section {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 14px;
    border: 1px solid #e0e6dc;
    border-radius: 14px;
}

.setting-section h3 {
    margin: 0 0 3px;
}

.danger-zone {
    border-color: #e8caca;
    background: #fffafa;
}

.danger-zone h3 {
    color: #8a3030;
}

.danger-zone p {
    margin: 0;
    color: #6d4a4a;
    font-family: Arial, sans-serif;
    font-size: 13px;
    line-height: 1.45;
}

.danger-zone[hidden] {
    display: none;
}

.settings-box label {
    font-size: 14px;
    font-weight: 700;
}

.settings-box input {
    width: 100%;
    height: 44px;
    border: 1px solid #aeb8a7;
    border-radius: 10px;
    padding: 0 12px;
    font-family: inherit;
}

.settings-box input[type="file"] {
    height: auto;
    padding: 9px;
    background: #fafbf9;
}

.backup-controls[hidden] {
    display: none;
}

.field-help {
    margin: 0;
    color: #5d6757;
    font-family: Arial, sans-serif;
    font-size: 13px;
    line-height: 1.4;
}

.file-explorer {
    overflow: hidden;
    border: 1px solid #d5ddd0;
    border-radius: 12px;
    background: #fff;
}

.explorer-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 6px 10px;
    border-top: 1px solid #e0e6dc;
    border-bottom: 1px solid #e0e6dc;
    background: #f7f9f5;
}

.explorer-toolbar > .secondary-button {
    min-width: 38px;
    min-height: 34px;
    padding: 0;
}

.folder-breadcrumbs {
    min-width: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    font-family: Arial, sans-serif;
    font-size: 14px;
}

.breadcrumb {
    border: 0;
    padding: 4px 2px;
    background: transparent;
    color: #355b2c;
    font: inherit;
    cursor: pointer;
}

.breadcrumb:hover,
.breadcrumb:focus-visible {
    text-decoration: underline;
}

.breadcrumb-separator {
    color: #75816d;
}

.explorer-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid #e0e6dc;
}

.explorer-actions #new-folder-name {
    width: auto;
    min-width: 0;
    flex: 1;
    flex-basis: 150px;
}

.picker-button,
.explorer-actions .secondary-button {
    min-width: 90px;
    min-height: 38px;
    padding: 0 12px;
    border: 0;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e6eae3;
    color: #172033;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.explorer-actions [hidden] {
    display: none;
}

.picker-button:hover,
.explorer-actions .secondary-button:hover {
    background: #dce5d5;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.visually-hidden:focus-visible + .picker-button {
    outline: 2px solid #355b2c;
    outline-offset: 2px;
}

.settings-box input.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.explorer-columns,
.file-list li {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) 75px 125px;
    align-items: center;
    gap: 8px;
}

.explorer-columns {
    padding: 8px 10px;
    background: #f7f9f5;
    color: #5d6757;
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 700;
}

.explorer-columns span:last-child {
    text-align: center;
    font-size: 12px;
}

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

.key-row input {
    min-width: 0;
    flex: 1;
    font-family: "Courier New", Courier, monospace;
    letter-spacing: 2px;
}

.key-row .secondary-button {
    min-width: 140px;
}

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

.file-list li {
    min-height: 42px;
    padding: 5px 10px;
    border-top: 1px solid #edf0ea;
    font-family: Arial, sans-serif;
    font-size: 13px;
}

.file-list li.folder-entry {
    background: #fbfcfa;
}

.file-list li:hover {
    background: #f1f5ee;
}

.item-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.item-icon {
    width: 18px;
    height: 15px;
    justify-self: center;
    position: relative;
    display: block;
}

.folder-icon {
    height: 12px;
    margin-top: 3px;
    border-radius: 2px;
    background: #e7bb55;
}

.folder-icon::before {
    content: "";
    position: absolute;
    top: -3px;
    left: 1px;
    width: 8px;
    height: 4px;
    border-radius: 2px 2px 0 0;
    background: #e7bb55;
}

.file-icon {
    width: 13px;
    height: 16px;
    border: 1px solid #8c9a83;
    border-radius: 2px;
    background: linear-gradient(to bottom, #fff 0 35%, #e8eee4 35% 45%, #fff 45%);
}

.item-type {
    color: #697363;
    font-size: 12px;
}

.item-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.folder-open,
.folder-action {
    border: 0;
    background: transparent;
    font: inherit;
    cursor: pointer;
}

.folder-open {
    color: #243d21;
    font-weight: 700;
    text-align: left;
}

.folder-action {
    color: #46523e;
    font-size: 12px;
}

.remove-file {
    border: 0;
    background: transparent;
    color: #8a3030;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 8px;
}

.form-actions .gbutton,
.form-actions .secondary-button {
    min-width: 140px;
}

.danger-button {
    align-self: flex-start;
    min-width: 140px;
    min-height: 42px;
    border: 1px solid #e8caca;
    border-radius: 25px;
    background: #fff;
    color: #8a3030;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
}

.danger-button:hover,
.danger-button:focus-visible {
    background: #fde8e8;
}

.back-button {
    align-self: flex-start;
    border: 0;
    background: transparent;
    color: #5d6757;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
}

@media (max-width: 520px) {
    .app {
        width: 100%;
        padding: 16px;
    }

    .projectbox,
    .created-project {
        width: 100%;
        max-width: 320px;
    }

    .home-card,
    .auth-box {
        padding: 24px 18px;
    }

    .dashboard-header {
        align-items: flex-start;
    }

    .dashboard-header h1 {
        font-size: 20px;
    }

    .dashboard-header .secondary-button {
        min-width: 90px;
    }

    .home-actions {
        flex-direction: column;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .gbutton,
    .form-actions .secondary-button {
        width: 100%;
    }

    .key-row {
        flex-direction: column;
    }

    .key-row .secondary-button {
        width: 100%;
    }

    .explorer-actions #new-folder-name {
        flex-basis: 100%;
    }

    .explorer-columns,
    .file-list li {
        grid-template-columns: 18px minmax(0, 1fr) 42px 95px;
        gap: 5px;
        padding-right: 6px;
        padding-left: 6px;
    }

    .item-actions {
        gap: 4px;
    }

    .folder-action,
    .remove-file {
        font-size: 11px;
    }

    .settings-box {
        max-height: calc(100vh - 32px);
    }
}