:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --border: #e2e2e6;
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --accent: #0071e3;
  --favorite: #ffb400;
  --radius: 14px;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.08), 0 14px 32px rgba(0, 0, 0, 0.12);
  --text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  text-shadow: var(--text-shadow);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 24px 40px;
}

.topbar h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-form {
  flex: 1;
  max-width: 480px;
}

.search-form input[type="search"] {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  text-shadow: var(--text-shadow);
}

.search-form input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  font-size: 13px;
}

.user-menu a {
  color: var(--text-muted);
  text-decoration: none;
  text-shadow: none;
}

.user-menu a:first-child {
  color: var(--text);
  font-weight: 500;
  text-shadow: var(--text-shadow);
}

.user-menu a:hover {
  color: var(--accent);
  text-shadow: none;
}

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-main {
  display: flex;
  justify-content: center;
  padding: 60px 20px;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  text-align: center;
}

.auth-card h1 {
  font-size: 22px;
  margin: 0 0 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  text-shadow: none;
}

.auth-form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  text-shadow: var(--text-shadow);
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-form button {
  margin-top: 4px;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-shadow: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.auth-form button:hover {
  opacity: 0.9;
}

.auth-link {
  display: inline-block;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  text-shadow: none;
}

.auth-link:hover {
  color: var(--accent);
}

.auth-error {
  color: #d70015;
  font-size: 13px;
  margin: 0 0 16px;
  text-shadow: none;
}

.auth-success {
  color: #1a7f37;
  font-size: 13px;
  margin: 0 0 16px;
  text-shadow: none;
}

.auth-hint {
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
  text-shadow: none;
}

.account-info {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 20px;
  text-shadow: none;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  text-shadow: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.back-link:hover {
  color: var(--text);
  text-shadow: var(--text-shadow);
}

.editbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.save-status {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 90px;
  text-align: right;
  text-shadow: none;
}

.edit-tools {
  display: inline-flex;
  gap: 4px;
  margin-right: 6px;
}

.editbar button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.edit-tools button {
  padding: 6px 10px;
  min-width: 32px;
}

.editbar button:hover {
  background: rgba(0, 0, 0, 0.04);
}

#btnEdit,
#btnSave {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  text-shadow: none;
}

.btn-pulse {
  animation: btn-pulse-anim 1.1s ease-in-out 3;
}

@keyframes btn-pulse-anim {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(0, 113, 227, 0); }
}

.btn-pdf {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
}

.btn-pdf:hover {
  background: rgba(0, 0, 0, 0.04);
}

main {
  padding: 0 40px 60px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 8px 0 16px;
  text-shadow: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1), 0 20px 40px rgba(0, 0, 0, 0.16);
}

.card-link {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 18px 18px 16px;
  text-decoration: none;
  color: inherit;
  min-height: 150px;
}

.card-folder {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  text-shadow: none;
  margin-bottom: 4px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  padding-right: 28px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-excerpt {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  text-shadow: none;
}

.card-meta {
  font-size: 11px;
  color: var(--text);
  margin-top: auto;
  padding-top: 10px;
}

.fav-form {
  position: absolute;
  top: 8px;
  right: 8px;
  margin: 0;
}

.fav-btn {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 6px;
  border-radius: 8px;
  text-shadow: none;
}

.fav-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.card.is-favorite .fav-btn {
  color: var(--favorite);
}

.empty-hint {
  color: var(--text-muted);
  font-size: 14px;
  text-shadow: none;
}

.preview-body main,
.preview-body {
  background: var(--bg);
}

.a4-wrap {
  display: flex;
  justify-content: center;
  padding: 0 40px 60px;
}

.a4-page {
  width: 210mm;
  min-height: 297mm;
  background: #fff;
  box-shadow: var(--shadow);
  border-radius: 4px;
  overflow: hidden;
}

.a4-frame {
  width: 100%;
  height: 297mm;
  border: none;
  display: block;
}

.context-menu {
  position: absolute;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  min-width: 200px;
}

.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--text);
  text-shadow: var(--text-shadow);
  border-radius: 6px;
  cursor: pointer;
}

.context-menu button:hover {
  background: var(--bg);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.modal-card h2 {
  font-size: 18px;
  margin: 0 0 12px;
}

.modal-hint {
  font-size: 13px;
  color: var(--text-muted);
  text-shadow: none;
  margin: 0 0 20px;
}

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

.modal-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  text-shadow: none;
}

.modal-card input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  text-shadow: var(--text-shadow);
}

.modal-card input:focus {
  outline: none;
  border-color: var(--accent);
}

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

.modal-actions button {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-shadow: var(--text-shadow);
  font-size: 14px;
  cursor: pointer;
}

#duplicateSubmit {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  text-shadow: none;
}
