:root {
    --bg-color: hsl(40, 20%, 97%);
    --text-color: hsl(0, 0%, 20%);
    --light-text: hsl(0, 0%, 50%);
    --border-color: hsl(40, 10%, 85%);
    --accent: hsl(200, 50%, 50%);
    --accent-light: hsl(200, 20%, 92%);
    --tag: hsl(90, 70%, 40%);
    --calendar-bg: hsl(40, 15%, 98%);
    --input-bg: hsl(40, 15%, 100%);
}

body.dark {
    --bg-color: hsl(0, 0%, 10%);
    --text-color: hsl(0, 0%, 90%);
    --light-text: hsl(0, 0%, 70%);
    --border-color: hsl(0, 0%, 20%);
    --accent: hsl(200, 50%, 60%);
    --accent-light: hsl(0, 0%, 18%);
    --tag: hsl(90, 50%, 40%);
    --calendar-bg: hsl(0, 0%, 12%);
    --input-bg: hsl(0, 0%, 15%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

button {
    -webkit-tap-highlight-color: transparent;
}

body {
    transition: background-color 0.3s, color 0.3s, font-family 0.3s;
    -webkit-font-smoothing: subpixel-antialiased;
    user-select: none;
    -webkit-user-select: none;
    cursor: default;
    background-color: var(--bg-color);
    color: var(--text-color);
}

body, body.font-serif {
    font-family: Georgia, 'Times New Roman', Times, serif;
    line-height: 1.5;
}

body.font-sans, logo, .footer {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', "Roboto Sans", 
        Roboto, "Helvetica Neue", Helvetica, sans-serif;
    line-height: 1.5;
}

body.mirror .post-title,
body.mirror .post-text,
body.mirror .post-edit-title,
body.mirror .post-edit-text,
body.mirror .new-post-title,
body.mirror .new-post-text
{
    transform: scaleX(-1);
}

::placeholder {
    color: var(--light-text);
    opacity: 0.3;
}

.magazine {
    max-width: 480px;
    margin: 0 auto;
    padding: 40px 20px;
}

.header {
    padding-bottom: 30px;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
    display: table;
    width: 100%;
}

.logo {
    display: table-cell;
    text-align: left;
    font-size: 1.4rem;
    font-weight: 400;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-color);
    vertical-align: middle;
}

.logo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: fit-content;
}

.logo-cell {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    color: white;
    border-radius: 5px;
    transition: background-color 0.3s;
    margin: 2px;
}

.logo-cell {
    background-color: hsl(var(--logo-hue, 200), 40%, 60%);
}

body.dark .logo-cell {
    background-color: hsl(var(--logo-hue, 200), 40%, 40%);
}

.icons {
    display: table-cell;
    text-align: right;
    vertical-align: middle;
    width: 100%;
    white-space: nowrap;
}

.icons span {
    cursor: pointer;
    display: inline-block;
    margin-left: 10px;
    color: var(--light-text);
    transition: color 0.2s;
    vertical-align: middle;
}

.icons span:first-child {
    margin-left: 0;
}

.icons span:hover {
    color: var(--accent);
}

.icons svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    display: block;
}

.post-title,
.post-edit-title,
.new-post-title {
    font-size: 1.7rem;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: -0.3px;
    color: var(--accent);
    width: 100%;
    background: inherit !important;
    font-family: inherit !important;
    width: 100%;
    border: none;
    background: none;
    outline: none;
    resize: none;
    overflow: hidden;
    display: block;
    user-select: text;
    -webkit-user-select: text;
}

.post-text,
.post-edit-text,
.new-post-text {
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-color);
    width: 100%;
    margin: 20px 0;
    background: inherit !important;
    font-family: inherit !important;
    border: none;
    outline: none;
    resize: none;
    overflow: hidden;
    display: block;
    user-select: text;
    -webkit-user-select: text;
}

.post-footer,
.post-edit-actions,
.new-post-actions {
    display: table;
    width: 100%;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.post-edit-save,
.post-edit-cancel,
.new-post-save,
.new-post-cancel {
    font-family: inherit;
    font-size: 0.9rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
    display: inline-block;
    line-height: 1;
}

.post-edit-save,
.new-post-save {
    color: var(--accent);
    float: right;
    margin-left: 15px;
}

.post-edit-save:hover,
.new-post-save:hover {
    color: var(--text-color);
}

.post-edit-cancel,
.new-post-cancel {
    color: var(--light-text);
    float: right;
}

.post-edit-cancel:hover,
.new-post-cancel:hover {
    color: var(--text-color);
}

.post-edit-save svg,
.post-edit-cancel svg,
.new-post-save svg,
.new-post-cancel svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    display: block;
}

.new-post-container {
    margin-bottom: 40px;
}

.post {
    margin-bottom: 40px;
    padding-bottom: 0;
}

.post.hidden {
    display: none;
}

.post-text p {
    margin-bottom: 1.5rem;
}

.post-text p:last-child {
    margin-bottom: 0;
}

.tag {
    color: var(--tag);
    cursor: pointer;
    transition: opacity 0.2s;
    display: inline-block;
}

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

.tag.active {
    font-weight: bold;
    text-decoration: underline;
}

.post-date {
    display: table-cell;
    text-align: left;
    font-size: 0.85rem;
    color: var(--light-text);
    font-style: italic;
    vertical-align: middle;
}

.post-actions {
    display: table-cell;
    text-align: right;
    vertical-align: middle;
    white-space: nowrap;
}

.post-action {
    display: inline-block;
    margin-left: 16px;
    cursor: pointer;
    color: var(--light-text);
    transition: color 0.2s;
    vertical-align: middle;
}

.post-action:first-child {
    margin-left: 0;
}

.post-action:hover {
    color: var(--accent);
}

.post-action svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    display: block;
}

.post.editing .post-header,
.post.editing .post-text,
.post.editing .post-footer {
    display: none;
}

.calendar-container {
    background-color: var(--calendar-bg);
    border: 1px solid var(--border-color);
    padding: 24px;
    margin-bottom: 40px;
}

.calendar {
    width: 100%;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    width: 100%;
}

.calendar-header button {
    background: none;
    border: none;
    color: var(--light-text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 12px;
    font-family: inherit;
    transition: color 0.2s;
}

.calendar-header button:hover {
    color: var(--accent);
}

.calendar-month-year {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-color);
    cursor: pointer;
    padding: 4px 12px;
}

.calendar-month-year:hover {
    color: var(--accent);
}

.calendar-weekdays {
    display: flex;
    width: 100%;
    margin-bottom: 15px;
    text-align: center;
    color: var(--light-text);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendar-weekdays div {
    flex: 1;
}

.calendar-weeks {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.calendar-week {
    display: flex;
    width: 100%;
    margin-bottom: 5px;
}

.calendar-day {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    cursor: pointer;
    color: var(--text-color);
    font-size: 0.9rem;
    transition: all 0.2s;
    border-radius: 4px;
}

.calendar-day.has-post {
    font-weight: 700;
    color: var(--accent);
}

.calendar-day.has-post:hover {
    background-color: var(--accent);
    color: white;
}

.calendar-day.today {
    border: 1px solid var(--accent);
}

.calendar-day.today.has-post {
    background-color: transparent;
    color: var(--accent);
    border-color: var(--accent);
}

.calendar-day.today.has-post:hover {
    background-color: var(--accent);
    color: white;
}

.calendar-day.selected {
    background-color: var(--accent);
    color: white;
}

.calendar-day.selected.has-post {
    color: white;
}

.calendar-day.selected.today {
    background-color: var(--accent);
    color: white;
    border: 1px solid var(--accent);
}

.calendar-day:hover {
    background-color: var(--accent-light);
    color: var(--text-color);
}

.calendar-day.empty {
    cursor: default;
    color: var(--light-text);
}

.calendar-day.empty:hover {
    background-color: transparent;
    color: var(--light-text);
}

.footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: table;
    width: 100%;
    color: var(--light-text);
    font-size: 0.85rem;
}

.copyright {
    display: table-cell;
    text-align: left;
    color: var(--light-text);
}

.controls {
    display: table-cell;
    text-align: right;
    color: var(--light-text);
    white-space: nowrap;
}

.controls span {
    display: inline-block;
    margin-left: 15px;
    cursor: pointer;
    vertical-align: middle;
    transition: color 0.2s;
}

.controls span:first-child {
    margin-left: 0;
}

.controls span:hover {
    color: var(--accent);
}

.controls svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    display: block;
}

.controls .key-toggle.has-key {
    color: var(--accent);
}
