:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --text: #1b252b;
  --muted: #63717a;
  --line: #d9e0e4;
  --blue: #2563eb;
  --green: #198754;
  --amber: #b7791f;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
}

button:hover {
  border-color: #9fb0bb;
}

.icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

button[type="submit"],
#entry-save {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
}

input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  display: none;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 36px);
  background: #eef5f3;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  border: 0;
  background: transparent;
  padding-left: 0;
}

.brand .icon {
  width: 18px;
  height: 18px;
}

nav {
  display: flex;
  gap: 8px;
}

.topbar-right,
.auth-actions {
  display: flex;
  align-items: center;
}

.topbar-right {
  gap: 12px;
}

.auth-actions {
  gap: 6px;
}

.auth-actions button {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
}

.auth-actions button:hover {
  color: var(--text);
}

.auth-actions .icon {
  width: 16px;
  height: 16px;
}

main {
  width: min(920px, calc(100vw - 28px));
  margin: 24px auto 56px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 20px;
}

#entry-form {
  display: grid;
  gap: 12px;
}

.toolbar,
.page-actions,
.search-bar,
.todo-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-bar,
.todo-form {
  margin-bottom: 14px;
}

.search-field,
.todo-form input {
  flex: 1;
}

.search-field {
  position: relative;
  min-width: 180px;
}

.search-field input {
  padding-right: 42px;
}

.input-clear {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  transform: translateY(-50%);
}

.input-clear:hover {
  background: #edf1f3;
  border-color: transparent;
}

.input-clear .icon {
  width: 15px;
  height: 15px;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 8px 12px;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.preview {
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.status {
  margin: 0;
  color: var(--muted);
}

.error {
  color: #b42318;
}

.login-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(360px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 24px;
}

.login-card h1 {
  margin: 0 0 4px;
}

.password-login-fields {
  display: grid;
  gap: 14px;
}

.login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.login-card.passkey-login-only #passkey-login-button {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

.list-panel ul {
  margin: 0;
  padding-left: 22px;
}

.list-panel li {
  margin: 8px 0;
}

.todo-list ul {
  margin: 0;
  padding-left: 22px;
}

.todo-list li {
  margin: 10px 0;
}

.todo-list input[type="checkbox"],
.markdown input[type="checkbox"] {
  width: auto;
  margin-right: 8px;
  vertical-align: middle;
}

.todo-list input[type="checkbox"]:not(:disabled) {
  cursor: pointer;
}

.todo-list label:has(input[type="checkbox"]:not(:checked)) {
  color: #b42318;
  font-weight: 700;
}

.empty {
  margin: 0;
  color: var(--muted);
}

a {
  color: var(--blue);
}

.page-actions {
  justify-content: flex-end;
  margin-bottom: 12px;
}

#page-title {
  margin-top: 0;
  color: var(--muted);
  font-size: 16px;
}

.markdown {
  line-height: 1.7;
  word-break: break-word;
}

.markdown h1,
.markdown h2,
.markdown h3 {
  line-height: 1.25;
}

.markdown pre {
  overflow: auto;
  border-radius: 6px;
  background: #172026;
  color: #f7fafc;
  padding: 12px;
}

.markdown code {
  border-radius: 4px;
  background: #edf1f3;
  padding: 2px 4px;
}

.markdown pre code {
  background: transparent;
  padding: 0;
}

.markdown img {
  max-width: 100%;
  border-radius: 6px;
}

@media (max-width: 640px) {
  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 14px 12px;
  }

  .topbar-right {
    display: contents;
  }

  .brand {
    justify-self: start;
  }

  nav,
  .toolbar,
  .page-actions,
  .search-bar,
  .todo-form {
    width: 100%;
    flex-wrap: wrap;
  }

  nav button {
    flex: 1 1 74px;
  }

  nav {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .auth-actions {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }
}
