/* Notepad - Refined minimal editor */

:root {
  --bg-page: #f7f5f0;
  --bg-editor: #fffefb;
  --bg-modal: rgba(44, 42, 38, 0.45);

  --text-primary: #2c2a26;
  --text-secondary: #6b6560;
  --text-muted: #9a9590;
  --text-accent: #8b3a2e;

  --border-light: #e8e4de;
  --border-focus: #c9c3bb;

  --accent: #c45c3e;
  --accent-hover: #a84d33;
  --success: #4a7c59;
  --warning: #b87d2e;
  --error: #b5423f;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow-soft: 0 4px 24px rgba(44, 42, 38, 0.06);
  --shadow-modal: 0 24px 60px rgba(44, 42, 38, 0.18);

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
  --font-mono: "SF Mono", "Monaco", "Inconsolata", "Fira Code", "Droid Sans Mono", monospace;

  --toolbar-height: 56px;
  --status-height: 40px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

body {
  min-height: 100%;
  font-family: var(--font-ui);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  min-height: 100vh;
}

/* Flash messages */
.flash {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  max-width: 360px;
}

.flash-error,
.flash-success {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-size: 14px;
  box-shadow: var(--shadow-modal);
  animation: slideIn 0.3s ease-out;
}

.flash-error {
  background: #fff5f5;
  color: var(--error);
  border-left: 3px solid var(--error);
}

.flash-success {
  background: #f4faf6;
  color: var(--success);
  border-left: 3px solid var(--success);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Editor layout */
.editor {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-top: calc(var(--toolbar-height) + var(--safe-top));
  background: var(--bg-editor);
}

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  height: calc(var(--toolbar-height) + var(--safe-top));
  padding: var(--safe-top) clamp(12px, 3vw, 32px) 8px;
  background: transparent;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  pointer-events: none;
}

.toolbar .actions {
  pointer-events: auto;
}

.actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: rgba(255, 254, 251, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
}

.actions button,
.actions .button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.actions button:hover,
.actions .button:hover {
  background: rgba(44, 42, 38, 0.06);
  color: var(--text-primary);
}

.actions button.primary {
  background: var(--text-primary);
  color: var(--bg-editor);
}

.actions button.primary:hover {
  background: #3d3b37;
}

.actions svg {
  display: block;
}

/* Banner */
/* Textarea */
#save-form {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#note-content {
  flex: 1;
  width: 100%;
  padding: clamp(24px, 5vw, 64px);
  padding-bottom: 24px;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: clamp(15px, 1.4vw, 18px);
  line-height: 1.75;
  tab-size: 2;
}

#note-content::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

#note-content:focus {
  background: rgba(255, 255, 255, 0.5);
}

/* Status bar */
.status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: calc(var(--status-height) + var(--safe-bottom));
  padding: 0 clamp(16px, 4vw, 48px) var(--safe-bottom);
  border-top: 1px solid var(--border-light);
  background: rgba(255, 254, 251, 0.92);
  backdrop-filter: blur(12px);
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.3px;
}

.save-hint-mobile {
  display: none;
}

#save-status {
  transition: color 0.3s ease;
}

.status-saved {
  color: var(--success);
}

.status-saving,
.status-pending {
  color: var(--warning);
}

.status-error {
  color: var(--error);
}

/* Card (login, etc.) */
.card {
  max-width: 420px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card-inner {
  background: var(--bg-editor);
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.card h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.card .subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 32px;
}

.card form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  color: var(--text-primary);
  font-size: 16px;
  font-family: var(--font-ui);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(196, 92, 62, 0.08);
}

.card button[type="submit"] {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--text-primary);
  color: var(--bg-editor);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
  margin-top: 8px;
}

.card button[type="submit"]:hover {
  background: #3d3b37;
}

.card .hint {
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.card a {
  color: var(--text-accent);
  text-decoration: none;
}

.card a:hover {
  text-decoration: underline;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-modal);
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--bg-editor);
  border-radius: var(--radius);
  padding: 32px;
  width: 92%;
  max-width: 420px;
  box-shadow: var(--shadow-modal);
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-content h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.modal-content form {
  margin-top: 20px;
}

.modal-content label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  margin-top: 16px;
}

.modal-content input {
  margin-bottom: 4px;
}

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

.modal-actions button {
  padding: 10px 18px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-actions button:hover {
  background: rgba(44, 42, 38, 0.05);
  color: var(--text-primary);
}

.modal-actions button.primary {
  background: var(--text-primary);
  color: var(--bg-editor);
  border-color: var(--text-primary);
}

.modal-actions button.primary:hover {
  background: #3d3b37;
}

.modal-actions button.danger {
  background: transparent;
  color: var(--error);
  border-color: rgba(181, 66, 63, 0.3);
}

.modal-actions button.danger:hover {
  background: rgba(181, 66, 63, 0.06);
}

.hint {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.hint.warning {
  color: var(--error);
  background: #fff5f5;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 24px 0 16px;
}

/* Responsive */
@media (max-width: 640px) {
  :root {
    --toolbar-height: 56px;
  }

  .toolbar {
    padding: var(--safe-top) 12px 8px;
  }

  .actions button,
  .actions .button {
    width: 44px;
    height: 44px;
    padding: 6px 10px;
    font-size: 13px;
  }

  #note-content {
    padding: 20px;
  }

  .save-hint-desktop {
    display: none;
  }

  .save-hint-mobile {
    display: inline;
  }

  .card-inner {
    padding: 28px;
  }

  .modal-content {
    padding: 24px;
  }
}

/* Focus visible for accessibility */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Selection color */
::selection {
  background: rgba(196, 92, 62, 0.18);
  color: var(--text-primary);
}
